mobx-router icon indicating copy to clipboard operation
mobx-router copied to clipboard

Multiple stores

Open eiktyrner opened this issue 7 years ago • 5 comments

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 avatar Nov 15 '16 16:11 eiktyrner

@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 avatar Nov 25 '16 10:11 kitze

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

LeonardoGentile avatar Feb 09 '17 16:02 LeonardoGentile

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

<Provider store={stores} {...stores}>
   <MobxRouter />
</Provider>

jayalfredprufrock avatar Mar 31 '17 18:03 jayalfredprufrock

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?

joshuaja avatar Sep 28 '18 14:09 joshuaja

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.

elilambnz avatar Jan 12 '19 08:01 elilambnz