How do you move a 500ms blocking task off the JS thread?
concurrency strategy in RN.
offload to a native module or C++ TurboModule, a worklet/worker thread, or chunk the work and yield; never block JS.
wrapping a synchronous loop in a Promise and assuming it stops blocking.
WHAT THIS TESTS: Understanding that JavaScript runs on a single thread, so freezes come from synchronous CPU work, and knowing the real options for parallelism in React Native.
A GOOD ANSWER COVERS: First diagnose that a 500ms freeze means a synchronous block on the JS thread. The strongest fix is to move the computation off the JS thread entirely. Options include writing a native module or a C++ TurboModule that performs the work on a background thread and returns the result asynchronously, or running the work on a separate JS runtime using a worker-thread or worklet library so it never touches the UI runtime. If the logic must stay in JS, the fallback is cooperative chunking: split the task into smaller batches and yield control between them, for example via InteractionManager or by scheduling slices, so frames can render between chunks.
COMMON WRONG ANSWERS: Wrapping the synchronous loop in a Promise, async function, or setTimeout and assuming it runs in parallel; the body still executes on the single JS thread and still blocks. Believing requestAnimationFrame parallelizes work. Assuming Hermes multithreads automatically.
LIKELY FOLLOW-UPS: How a worklet runtime gets its own thread, the cost of serializing data to a native thread, when chunking is preferable to native offloading, and how the new architecture makes background native work easier.
ONE CONCRETE EXAMPLE: Parsing and sorting a large CSV on tap froze the UI. Moving the parse into a C++ TurboModule that runs on a background thread and resolves a Promise with the result kept the JS thread free, so a loading spinner animated smoothly while the heavy work completed off-thread.
Read the original → reactnative.dev
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.