-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adds support for async routes #13
Conversation
…he matched "components" into account
if (route.components) { | ||
const foundNamedComponent = Object.keys(route.components) | ||
components.some((matchedComponent, i) => { | ||
if (typeof matchedComponent === 'object') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably use lodash.isplainobject
here since we have it as a dependency already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
result.name = key; | ||
matchedComponent = matchedComponent[key]; // eslint-disable-line no-param-reassign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that this mutation does not cause any problems? Seems like we are modifying renderProps
indirectly here, no risk in doing so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it doesn't (it just changes the bound matchedComponent
-parameter).
But might be a bit too clever. I'll re-write it to make the intent easier to read
Looks good! We should probably add an example where we use async routes to verify that it also works in a "real" application. |
@dlmr Refactored |
Adds support for async routes by not only taking "routes", but also the matched "components" into account. This allows us to lazily load routes using webpacks code-splitting feature while preserving support for
get-
andsetProps
.