~/talk

Let's Build React Context From Scratch in JS

Talkat code.talks 2023 · 2023-09-14..09-15· [react, javascript]
slides:none on file

Builds a tiny React-like Context from scratch in plain JavaScript and proves it works by wiring it into a minimal unit test framework (a Jest-like pest) so describe blocks and tests share messages without props or globals. Uses closures and the call stack to implement createContext with provider/consumer semantics, fixes nesting by restoring previous values, and publishes the result as a package named context. Notes Node has native equivalents via async local storage and a related JS proposal.

AI-written summary · about

  1. 0:00Introduction
  2. 3:22Unit testing framework
  3. 8:24React Context concept
  4. 10:54JavaScript closures
  5. 12:38JavaScript call stack
  6. 13:20Live coding setup
  7. 15:11Basic unit testing library
  8. 16:39Designing Context API
  9. 19:16Context provider and consumer
  10. 21:05Testing nested contexts
  11. 23:17Fixing context restoration bug
  12. 24:02Finalizing Context implementation
  13. 24:24Personal projects and npm package
  14. 25:07Async context proposals
  15. 26:13Closing thoughts
~/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.