React Native & Expo (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is the difference between Threading in React Native?
senior LevelCode Examplereact-nativeAdvanced Internals
In Simple Words: A React Native app runs on 4 primary threads:
- JavaScript Thread: Executes your business logic, React rendering, API calls, and state management.
- UI Thread (Main Thread): Android/iOS OS thread responsible for drawing views and handling user touch interactions.
- Shadow Thread: Background C++ thread where the Yoga layout engine computes layout coordinates before passing to UI thread.
- Native Modules Thread: Background thread pool where native platform modules execute tasks (e.g. Geolocation, File system).
text
React Native Threading Model:
[JS Thread (React Code)] ──► [Shadow Thread (Yoga C++ Layout)]
│
▼
[Native Thread (Background Tasks)] ──► [UI / Main Thread (Native OS Drawing)]