~/talk

Let's Build React Context From Scratch in JS

Talkat CityJS Athens 2025 · 2025-05-28..05-31· [react, javascript]
slides:none on file

Builds a minimal React-like Context API in plain JavaScript using closures and the language's synchronous blocking behavior, implements createContext/useContext by returning a provider/consumer pair that sets and reads a module-scoped currentValue, handles nested describes, and fits in about 10 lines of JavaScript. Shows the failure mode with async code, explains fixes via bound closures and Node's async local storage / async hooks, and mentions a published npm package named "context" that mirrors this approach.

AI-written summary · about

  1. 0:00Introduction and speaker
  2. 3:13Building a unit test library
  3. 7:25React Context inspiration
  4. 10:16Implementing context from scratch
  5. 16:21Fixing context leakage
  6. 18:51Limitations and async code
  7. 19:57Conclusion and package promotion
~/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.