My personal summary is that new context is ready to be used for low frequency unlikely updates (like locale/theme). It's also good to use it in the same way as old context was used. I.e. for static values and then propagate updates through subscriptions. It's not ready to be used as a replacement for all Flux-like state propagation.
Granted the example shown here deals with "locale/theme" data — the issue is that it would be all too easy to get the impression that it is OK to store "regular data" within context.
For example Redux and MobX simply store an access point that never changes during the entire application session within context.
That (never changing) access point makes it possible to subscribe to updates from the library runtime. Once the subscribed, context is rarely involved in component ⬌ data exchanges.
Context is how state (that exists somewhere already) is shared with other components.
Context has little to do with state *management*.
01:56 AM - 09 Jan 2021
Phrased differently: Context is a place for "first introductions" between components and cross-component state (management) but not for "regular meetings" between them.
In my opinion the countless "don't need Redux, just use Context" statements communicate a misunderstanding of what context actually is.
There are "lighter" (cross-component) state management solutions like unistore, valtio, zustand and jotai.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
sebmarkbage 2018
Granted the example shown here deals with "locale/theme" data — the issue is that it would be all too easy to get the impression that it is OK to store "regular data" within
context
.For example Redux and MobX simply store an access point that never changes during the entire application session within
context
.That (never changing) access point makes it possible to subscribe to updates from the library runtime. Once the subscribed,
context
is rarely involved in component ⬌ data exchanges.I am Sorry, I should have mentioned about the things me might store in Context (like which changes not on regular basis) and the things we might not.
No need to apologize — for the most part the official docs are silent on the matter and I only became aware of it through Mark Erikson's Why React Context is Not a "State Management" Tool.
Phrased differently: Context is a place for "first introductions" between components and cross-component state (management) but not for "regular meetings" between them.
In my opinion the countless "don't need Redux, just use Context" statements communicate a misunderstanding of what context actually is.
There are "lighter" (cross-component) state management solutions like unistore, valtio, zustand and jotai.