Skip to content

karczewskiPiotr/crude-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crude React

This project is a crude recreation of React library purely for fun/educational purposes.

The scope of this project encapsulates the client side part of React in its pre RSC era.

For the best understanding of the operation I would suggest starting with :

  • JSX transpilation
  • render phase
  • commit phase

If you want to peek at the results of JSX transpilation take a look at out/index.js or use the Bun.Transpiler

TLDR on React Fiber and Element

You will encounter two main interfaces while looking through this codebase. One of the will be a React.Element and another one will be React.Fiber.

You can think of React.Element as an object representation of the JSX that gets passed down to the render function.

React.Fiber is a representation of the work that needs to be done to render the elements. It takes a form of a tree, which is composed of singly-linked list of child nodes linked to each other (sibling relationship) and a doubly-linked list of parent-child relationships.

React Fiber

Getting started

To install dependencies:

bun install

To run:

bun run build # builds the crude react library into out/
bun run serve # runs a simple http server with a playground

This project was created using bun init in bun v1.1.10. Bun is a fast all-in-one JavaScript runtime.


Big shout-out to some great resources:

About

Crude recreation of React library for fun/educational purposes.

Resources

Stars

Watchers

Forks