- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does the Fabric architecture work in React Native?
React Native's Fabric architecture is a performance-focused update to the traditional React architecture. It uses asynchronous rendering and a new reconciliation algorithm to improve app performance and reduce the time it takes to update the UI. Fabric also allows for more efficient use of memory and better handling of complex animations and interactions.
The Problem
In the current architecture, all the UI operations are handled by a sequence of cross-bridge steps. There are four core sections in the current architecture −
The React code written by the developer (which is very similar to its web counterpart),
The JavaScript that gets interpreted from what you write,
A series of elements collectively known as “The Bridge,”
And the Native side.
The key aspect of the current architecture is that the two realms, JavaScript and Native, are not “aware” of each other. This means that to communicate, they rely on asynchronous JSON messages transmitted across The Bridge. These are sent to the native code with the expectation (but not a guarantee) that they will elicit (manage to get) a response sometime in the future.
The Solution (Fabric Architecture)
The new architecture (Fabric architecture) mainly consists of two main components −
Layout Engine
The layout engine is responsible for calculating the layout of a component and its children.
It uses a new algorithm called Yoga, which is a fork of Facebook's Yoga layout engine. Yoga is more efficient than the traditional layout engine and is able to calculate layout faster and with less memory usage. This results in improved performance for complex and large components.
Renderer
The renderer is responsible for rendering the component on the screen.
It uses a new technique called async rendering. This allows the renderer to work on multiple components at the same time, which improves performance and reduces the amount of time it takes to render a component.
How it works (Fabric Architecture)
React Native app starts via user interaction.
The new Fabric architecture loads the native side instead of opening the native modules.
Then it notifies the JS thread to do their side of things.
Now the JS side loads all the main.bundle.js which contains all JavaScript and React components logic.
JS called through the ref native function (the one that was exposed as an object using the JSI API) to Fabric and the shadow node creates the tree as before.
And at last Yoga does the layout calculation converting from flexbox-based style to host layout.
Fabric does its thing and shows the UI.
Overall, the Fabric architecture in React Native provides a more efficient and performant way to slayout and render components, resulting in a smoother user experience.
- Related Articles
- How does React work?
- How to use Flexbox in React Native?
- What is React Native?
- How to display loading indicator in React Native?
- How to use Redux with React Native?
- How to install yup in react native in JavaScript?
- What are props in react native?
- What is Metro in React-Native?
- Explain the importance of SafeViewArea in React Native?
- Explain the working of Animations in React Native?
- How to display Material Chip View in React Native?
- What is a state in react native?
- How to load data from a server in React Native?
- Explain working of the Modal window in React Native
- List the important core components of React Native
