tranbathanhtung / React Fiber Implement
re-implement react fiber
Stars: ✭ 520
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
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
State Threads
Light-weight thread library, coroutine or c++ goroutine , patched for SRS.
Stars: ✭ 500 (-3.85%)
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
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
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
- React Components, Elements, and Instances
- Design Principles
- React Fiber resources
- The how and why on React’s usage of linked list in Fiber to walk the component’s tree
- In-depth explanation of state and props update in React
Recommend
- Lin Clark - A Cartoon Intro to Fiber - React Conf 2017
- A look inside React Fiber
- Build your own React Fiber
- React Fiber Architecture @acdlite and React Fiber Architecture @SaeedMalikx
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].