-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Code splitting problem in 1.0.0-beta2 #1402
Comments
I am currently fighting this battle and I think it's related to the async patterns for loading components and routes. What I think happens is that one of the async loops completes, presenting the routes to the Router but with I've not worked out how to mitigate this problem yet, I would assume it will require some addtional async control flow to ensure that both |
Just to add to this, the following is the console output when I was debugging the issue. It's exactly as I described above, the Router is mounted and starts the async process of resolving routes and getting the components for the route branch, however, this does not complete before an initial render of the router (which does not have components). I think this is where the noscript is output. Then the async process of getting components returns, calling the callback passed to I guess the issue here is how to cancel the first render of the Router until the components are returned from
|
After some further conversations on this in the React thread I've managed to workaround this issue. The key is to setup the routes ahead of the first render so I've essentially run the server-side rendering code again but then rendered the client-side version: const history = new BrowserHistory();
if (typeof history.setup === "function") {
history.setup();
}
Router.run(routes, history.location, (err, initialState, transition) => {
React.render(<Provider redux={redux}>{() => <Router key="ta-app" history={history} children={routes} />}</Provider>, document.getElementById('ta-app'));
}); This appears to be working for me. |
👍 |
Doing this causes the runTransition to happen twice. @anatomic or @heebtob Can you try out my PR here #1490 to see if you still get the odd behavior? What this pr does is detect if the location object is actually a history object. Then extracts the location object, passing down the history object and routes object down with the initial state so Router run works client side. Your code would then be reduced to: const history = new BrowserHistory();
Router.run(routes, history, (err, initialState, transition) => {
React.render(<Provider redux={redux}>{() => <Router key="ta-app" ...initialState />}</Provider>, document.getElementById('ta-app'));
}); |
this sounds like basic functionality that isn't working, so I'm closing since we're reworking the server rendering story a little bit right now, and we'll have tests around pretty basic functionality. |
@ryanflorence Can you point me to the new server rendering stuff? |
I use server side rendering with fluxible and react router.
I have some routes with code splitting like the following
As soon as I go to a route with code splitting in place I get the following warning in the browser
React checks the server side generated markup against the following markup and says it can not be reused because it's differrent.
The text was updated successfully, but these errors were encountered: