mobx-router
mobx-router copied to clipboard
Multiple stores
Is it possible to use this package with multiple stores? Or do you need a "root" store like in your examples?
I'd rather not have just a single store available for injecting like your example export default observer(['store'], Gallery);
My current setup with ReactRouter is along these lines (from memory so syntax might be off..)
export {
userStore,
imageStore,
}
import * as stores from "stores"
<Provider {...stores}>
<Route />
</Provider>, document.getElementById('root')
I couldn't get the startRouter to work with this type of setup. Any input?
@eiktyrner Thanks for the suggestion. Right now I'm using a single store object for my mobx apps but you're right, this should be supported too. Also see the discussion in #12 👍
@kitze Just right after having installed this I found the same problem as @eiktyrner. Any update or workaround on this?
Thanks for sharing this by the way 👍 👍
For now I'm doing this and always injecting specific stores instead of the store
collection.
<Provider store={stores} {...stores}>
<MobxRouter />
</Provider>
I just ran into this as well. The generic MobX error made it a bit difficult to track down. Any plans to support a custom store name instead of requiring store
?
Combining multiple stores is recommended as best practice if you plan to have multiple stores.
Also, +1 for support to have a custom name instead of store
.