Idea: get rid of the restriction on changing set of stores in Provider #745
Description
@mweststrate We had a discussion about the restriction on changing set of stores in Provider
with @FredyC. What do you think about removing this restriction?
The quote from the change log for mobx-react@6.0.0
:
- Changing the set of stores in
Provider
is no longer supported and while throw a hard error (this was a warning before), as the model ofProvider
/inject
has always been to inject final values into the tree. (That is, fixed references, injected objects themselves can be stateful without problem). If you want to dynamically swap what is provided into the tree, useReact.createContext
instead ofProvider
/inject
. The suppressChangedStoreWarningflag for
Provider` has been dropped.
a64c2d3#diff-4ac32a78649ca5bdd8e0ba38b7006a1eR11
I am thinking if this is still valid actually. Isn't it from legacy context too? I think it's because the legacy context could not propagate to pure components. The Context does not have that problem. I don't see a reason why the value could not change. I mean in MobX world it doesn't usually need to, but people are crazy sometimes :)
Looking at those links it's clear it's related to the legacy context and as such it's misleading.
I am really convinced we shouldn't prevent this if someone really wants that. There is no actual harm in that. It's not about recreating stores, just the context object itself and the only downside is it will re-render a whole tree from that Provider.