~/talk

Multithreading in React: A guide to Web Workers

Talkat reactjsday 2024 · on Friday, 2024-10-25· [react, web-platform]
name:Dani Coll
github:dani-coll
slides:none on file

Claim: offload heavy computation to Web Workers to get true parallelism so React UI stays responsive. Implementation uses new Web Worker with postMessage / onmessage, a reusable useWebWorker hook, and the js-chess-engine + react-chess demo. Chess positions have more than 20 legal moves and branches up to ~45 making depth ~10–15 searches expensive. The demo moves the engine into a worker, spinner updates and best move returns (e g Ng1→f3), but workers cannot touch the DOM and large payloads incur copy overhead.

AI-written summary · about

  1. 0:00Multithreading in React intro
  2. 1:24JS engine and call stack
  3. 2:27Sync vs async in JS
  4. 8:34Async isn't multithreading
  5. 9:16Web Workers for chess AI
  6. 11:03Web Workers in React
  7. 13:12Live React chess demo
  8. 16:30Reusable worker hook
  9. 23:33Worker in React
  10. 27:35Testing worker implementation
  11. 28:16When to use workers
  12. 30:54Worker limits and trade-offs
  13. 31:37Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.