-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async import state #40
Comments
I see that redux has some async feature (actions/flow) but it is to load data asynchronously. I think you want to enable lazyloading / webpack code splitting for stores, but I'm not sure it can be possible with the current RFX stores structure. For example I see that with redux is possible to lazyload reducers. Maybe in RFX we may lazyload actions but they must be decoupled from stores. |
I figured as much, seems to be a mobx thing then. I'll close this then. |
If you have an implementation please share it. |
I would be pretty dope to do that and also save a few bytes. Yeah I got it working after a couple of minutes, but it's not pretty... Something like this: export default store => (
<Route path="/" component={AppLayout}>
<IndexRoute
getComponent={(loc, cb) => {
import('./stores/home').then(module => store.home = module.default);
return $import(loc, cb, 'Home')
}}
/>
etc....
</Route>
) I'll play with it more tomorrow! |
The problem I'm trying to solve know is ssr... |
@foxhound87 It can be done with react-router but it's not optimal. I will probably use it but maybe implement it when mobx-router has support for ssr and code splitting? Have you tried it? |
Not yet, but when mobx-router will be ready |
I'm still feeling my way around react/mobx/etc, but it seems like the (controversial) react-router v4 makes it possible to address all these things simultaneously. I read through this article , and it seems that you can hit all requirements with the new version. Any thoughts on migrating to react-router v4? |
Thank you for the article. In the meanwhile mobx-router reaches SSR and async functionalities, the main libs like react-router have to be upgraded anyway. I can make a new branch for those who want to contribute. |
I'd be happy to help |
Great @mattiasewers ! Made it: https://github.com/foxhound87/rfx-stack/tree/react-router-4 |
Now that react router v4 is released, their documentation said this about code-splitting and server-side rendering.
Tbh I havent't tried v4 yet but it seems like react-router might be a hack for this stack. So stick with v3 until mobx-router is ready or something else or try to implement v4? What do guys think? |
At this point doesn't worth the effort for this upgrade, at least until those functionalities will be officially supported (but it seems very unlikely). Let's see the mobx-router future development |
I have specific stores for some routes, would it be possible to requires those async? I know it's possible with redux. Maybe pass the store to react-router? I'll se what I can do
The text was updated successfully, but these errors were encountered: