Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Idea: get rid of the restriction on changing set of stores in Provider  #745

Closed
@vkrol

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 of Provider / 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, use React.createContext instead of Provider / inject. The suppressChangedStoreWarningflag forProvider` 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 :)

#739 (comment)

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.

#742 (comment)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions