Skip to content
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

feat(routing): Code splitting, named routes, no SSR mismatch issues #1298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

grgur
Copy link

@grgur grgur commented Oct 14, 2016

I reused @leifdalan's PR #1216 to enable code splitting with additional features:

  • named chunks (use custom names instead of numbers for chunks)
  • proper matching in client's to avoid server-client rendering differences

}
}
const routes = getRoutes(store);
match({ history, routes: routes }, () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match is useless here, no ?

You don't use parameters of callback, can you explain to me why you have put a match?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. match is going to wait until React Router has finished getting components. In other words, React Router will fetch chunks and tell us via match when it's ready to render the entire view.
If we don't wait then React Router will render the view without chunks and that view will be different than what we got from server side rendering. This will cause React to discard SSR content.

childRoutes: [{
path: 'login',
getComponent(nextState, cb) {
console.time('gettingComponent');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to leave these console.time calls in? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants