All Projects → tranbathanhtung → React Fiber Implement

tranbathanhtung / React Fiber Implement

re-implement react fiber

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Fiber Implement

React Tiny Dom
🍙 A minimal implementation of react-dom using react-reconciler
Stars: ✭ 432 (-16.92%)
Mutual labels:  fiber, react-dom
React Ssr Prepass
A custom partial React SSR renderer for prefetching and suspense
Stars: ✭ 411 (-20.96%)
Mutual labels:  react-dom
postonents
React meets Emails | ⚛️ x 📧= 🔥
Stars: ✭ 90 (-82.69%)
Mutual labels:  react-dom
Vertx Zero
Zero Framework:http://www.vertxup.cn
Stars: ✭ 320 (-38.46%)
Mutual labels:  fiber
ore-ui
💎 Building blocks to construct game UIs using web tech.
Stars: ✭ 122 (-76.54%)
Mutual labels:  fiber
React Particles Webgl
🔆 A 2D/3D particle library built on React, Three.js and WebGL
Stars: ✭ 330 (-36.54%)
Mutual labels:  fiber
rc-dock
Dock Layout for React Component
Stars: ✭ 318 (-38.85%)
Mutual labels:  react-dom
State Threads
Light-weight thread library, coroutine or c++ goroutine , patched for SRS.
Stars: ✭ 500 (-3.85%)
Mutual labels:  fiber
React Reparenting
The reparenting tools for React
Stars: ✭ 390 (-25%)
Mutual labels:  fiber
Xxl Tool
a series of tools that make Java development more efficient.(Java工具类库XXL-TOOL)
Stars: ✭ 311 (-40.19%)
Mutual labels:  fiber
Realize
A React component tree visualizer
Stars: ✭ 285 (-45.19%)
Mutual labels:  fiber
react-exif-orientation-img
NOT MAINTAINED ANYMORE - img element wrapper component for React that understands EXIF orientation information and corrects it using CSS transforms.
Stars: ✭ 24 (-95.38%)
Mutual labels:  react-dom
React Suspense Starter
Experiment with React Suspense right meow.
Stars: ✭ 370 (-28.85%)
Mutual labels:  react-dom
remote-frames
Render a subset of the React tree to a different location, from many locations, without having to coordinate them
Stars: ✭ 27 (-94.81%)
Mutual labels:  react-dom
Fibjs
JavaScript on Fiber (built on Chrome's V8 JavaScript engine)
Stars: ✭ 2,880 (+453.85%)
Mutual labels:  fiber
alist fiber
一款基于go+vue的阿里云盘项目 https://pan.baiyue.one
Stars: ✭ 53 (-89.81%)
Mutual labels:  fiber
React Tree Walker
Walk a React (or Preact) element tree, executing a "visitor" function against each element.
Stars: ✭ 318 (-38.85%)
Mutual labels:  react-dom
Libfiber
The high performance coroutine library for Linux/FreeBSD/MacOS/Windows, supporting select/poll/epoll/kqueue/iocp/windows GUI
Stars: ✭ 519 (-0.19%)
Mutual labels:  fiber
Under The Hood Reactjs
Entire React code base explanation by visual block schemes (Stack version)
Stars: ✭ 4,794 (+821.92%)
Mutual labels:  fiber
React Dev Inspector
This package allows users to jump to local IDE code directly from browser React component by just a simple click
Stars: ✭ 372 (-28.46%)
Mutual labels:  fiber

React fiber

react-fiber is my self-study project help me understand how react work. In fact, all codebase re-implement each step , so it looks similar to the source code of react. Though, I think it's still smaller and easier to understand than when you actually read the react source code. I hope it helpful for people who want to start learn how react fiber work.

Something you should read and learn before start read source code

Keyword, Algorithms and Data Structure Used

  • Single linked list, Circular linked list
  • Simple stack and queue
  • Recursive
  • Structural sharing
  • Reconciliation
  • Scheduler
  • Bitwise Operators
  • JSX
  • DOM
And more
Recommend

Overview

Fiber tree

Inside Fiber: in-depth overview of the new reconciliation algorithm in React

Keyword

work (unitOfWork): A component, node element => fiber

current: Current fiber what is displayed on browser

WIP (workInProgress): New fiber tree we will build

fiber: {
  type: string | Function ('div', 'span', function Button)
  instanceNode: HTMLElement (div, span)
  return: fiber (parent of fiber)
  child: fiber (child of fiber)
  sibling: fiber (sibling of fiber)

  alternate: link current - WIP and WIP - current
  effectTag: number (give we know what will happen this fiber)

}

requestIdleCallback

main function:
  createWorkInProgress()
  beginWork()
  reconcileChildren()
  completeWork()
  commitWork()

Process of first render

Render -> Reconciler -> Scheduler ->
Begin Work (build fiber tree) -> ChildReconciler(create child and effectTag) -> if work has child we will continue to run beginWork -> no child ->              
Complete Work (build list effect, mark tag and create instanceNode) -> sibling has child -> turn back Begin Work -> no child -> Complete Work -> no sibling -> has a new tree with effect tag ->
Commit Work : It will base on list effect tag to commit each fiber (Placement, Update, Delete, Lifecycle)

// In first render current fiber is null.
// current is workInProgress when commit

Process when update

Do something ->
Get current Fiber what corresponding to the component ->
Recursive to find Root ->
Clone fiber from root to component has update ->
Begin Work from this fiber (it's maybe clone fiber when children of component use memo, pure component or use shouldComponentUpdate) ->
Complete Work ->
Commit Work

About With(Hook v16.7)

Hooks are stored as a linked list on the fiber's prevState field of fiber.
current tree - current hook <=> WIP - WIP hook

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].