kitze / mobx-router

A simple router for MobX + React apps
509 stars 66 forks source link

Multiple stores #9

Open eiktyrner opened 8 years ago

eiktyrner commented 8 years ago

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?

kitze commented 8 years ago

@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 👍

LeonardoGentile commented 7 years ago

@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 👍 👍

jayalfredprufrock commented 7 years ago

For now I'm doing this and always injecting specific stores instead of the store collection.

<Provider store={stores} {...stores}>
   <MobxRouter />
</Provider>
joshuaja commented 6 years ago

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?

elilambnz commented 5 years ago

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.