How many threads run in React Native?

The React Native app contains the following thread:

  • React Native UI Thread (Main Thread): This thread is used for the layout of the mobile app.
  • React Native JavaScript Thread: It is a thread where our business logic will run. It means JS thread is a place where our JavaScript code is executed.
  • React Native Modules Thread: Sometimes, our app needs access to platform API, which happens as a part of native module thread.
  • React Native Render Thread: This thread is used to generate actual OpenGL commands used to draw the app UI.

 

In React Native, there are typically two main threads that run:

  1. JavaScript Thread: This thread is responsible for running your JavaScript code. It handles tasks such as UI updates, business logic, and network requests.
  2. Native UI Thread: This thread is responsible for rendering the native components and handling the native UI. It communicates with the JavaScript thread through a bridge, exchanging information about UI updates and user interactions.

These two threads work together to create a smooth user experience. It’s important to note that heavy computations or long-running tasks in the JavaScript thread can impact UI responsiveness, so it’s a good practice to offload intensive tasks to separate threads when needed. Additionally, React Native allows the use of Web Workers for background tasks, which can further improve performance.