React Fiber resources
This is a repository for resources about React Fiber.
React Fiber is a new React reconciliation algorithm, which started using from v16. React Fiber makes many features like Suspense and Concurrent Mode possible.
Concurrent Mode is still in experimental stage, but React already has the documentation so you can see what Concurrent Mode makes possible at the documentation.
https://reactjs.org/docs/concurrent-mode-intro.html
React internal algorithm
If you are not familiar with React internals, I recommend you reading the documentations first, which are very helpful resources.
React Fiber
Articles & Slides
- React Fiber Architecture
- Fiber Principles: Contributing To Fiber #7942
- How React Fiber Works
- React Internals
- Capability of React Fiber
- A look inside React Fiber - how work will get done
- Build your own React Fiber
- Algorithms in React
- Implementation notes on react's scheduling model as of (shortly before) 16.8.0
Videos
- Dan Abramov: Beyond React 16
- Andrew Clark: Roadmap for React Fiber and Beyond
- The Evolution of React and GraphQL at Facebook and Beyond
- Lin Clark - A Cartoon Intro to Fiber - React Conf 2017
- Sebastian Markbåge - React Performance End to End (React Fiber)
- Andrew Clark: What's Next for React — ReactNext 2016
- Why, What, and How of React Fiber with Dan Abramov and Andrew Clark
- A tiny Fiber renderer
React Fiber function call stacks
[Note] React Fiber now behaves as synchronous by default. See #8127. This call stacks are results in the time when it behaved as asynchronous.
ReactDOMFiber
ReactDOM
ReactDOMFiber with 10000 items (Async Scheduling)
--- working asynchronously ---------------------------------------------------------------------------
| ------- Fiber --------------- ------- Fiber --------------- ------ Fiber --------------- |
| | beginWork -> completeWork | -> | beginWork -> completeWork | -> |beginWork -> completeWork | ... |
| ----------------------------- ------------------------------ ---------------------------- |
------------------------------------------------------------------------------------------------------
↓↓↓
-----------------------------------------------------------------------
| commitAllWork(flush side effects computed in the above to the host) |
-----------------------------------------------------------------------
ReactDOMFiber with 10000 items (Sync Scheduling)
ReactDOM with 10000 items
React Fiber call tree
Related Words
- Fiber
- Call Stack
- Coroutine
- Continuation
- Algebraic Effects
Custom Renderer Interface
React doesn't depend on any specific environments like DOM and React provides us a way to create own custom renderers based on Fiber reconciliation. ReactDOM and ReactNative are implemented as one of the custom renderers.
I've presented about the custom renderer; here is the link to the slide.
- https://speakerdeck.com/koba04/make-it-declarative-with-react
- https://github.com/koba04/jsconf-jp-presentation
The following is a custom renderer named react-fs
, which is a renderer for fs
package
const React = require('react');
const { ReactFS } = require('@koba04/react-fs');
const targetDir = "test-react-fs-project";
ReactFS.render(
<>
<file name="README.md">
# Title
</file>
<directory name="src">
<file name="index.js">
console.log("Hello");
</file>
</directory>
</>,
targetDir
);
ReactNoop
ReactNoop is a renderer for React Fiber, which is using for testing and debugging.
It is very useful to understand React Fiber renderer!!