zustand/docs/previous-versions
jroitgrund 17e281fd75
docs: strict null check in createContext example (#2995)
* docs: prefer useState in createContext example

Both useState and useRef are correct in practice: useState will only render once since we never set the state after initializion, and useRef is safe to use since the component never needs to rerender when the ref value changes.

However, lint rules will flag useRef as a mistake, because we are passing a ref value to a child component, which in general can cause stale components since changing refs doesn't trigger re-renders.

* formatting

* explicit null check
2025-03-20 21:23:42 +09:00
..