4 ms·
> How do two separate components access the one store, singletons? You can use <Provider> and @inject to put a store onto the component tree and pull it off wh
by timdorr 9y ago
> How do two separate components access the one store, singletons?
You can use <Provider> and @inject to put a store onto the component tree and pull it off whenever you need it. It's just a quick wrapper around the React context API.
> If two components observe the same store but render different attributes of it are they both updated when the store is updated?
Yes, this is just how Mobx works. Observations are set up implicitly. You can observe any @observable value or @computed function just by referencing it within an @observer.
> Are you limited to modifying your store only in your component?
Nope, this works with just plain JavaScript. The main library doesn't offer any React-specific bindings (like Redux), so it can be used with anything.