finds.dev← search

// the find

jamiebuilds/unstated-next

★ 4,191 · TypeScript · MIT · updated Feb 2022

200 bytes to never think about React state management libraries ever again

A thin wrapper around React Context that turns a custom hook into a typed container with a Provider and a useContainer hook. The actual implementation is about 20 lines. It's for teams that want structure around the useState+useContext pattern without pulling in Redux or Zustand.

The createContainer abstraction eliminates the null-default context footgun — no more createContext(null) and then asserting non-null inside every consumer. TypeScript inference works well because the container type flows directly from the hook's return type. The composable container pattern (using one container inside another hook) is a genuinely useful pattern that the docs explain clearly.

Last commit was 2022; React has moved on with useContext optimizations and the ecosystem has largely settled on Zustand or Jotai for this niche — both of which solve the re-render problem this library punts on. No built-in selector support means any state change in the container re-renders all consumers, and the docs' mitigation advice (useMemo, React.memo) is boilerplate the user has to write themselves every time. At 4k stars with no recent activity, the bet that Redux would die and this would win clearly did not play out.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →