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
Upgrade to React Router v4 #667
Conversation
The current problem I am having is that the location is passed as a context prop, not a true prop. So, for example, if you go from one collection to another, the URL will update, but the list of entries will not, as it still gets the original Here is a document on the fixes: https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/blocked-updates.md. @erquhart @Benaiah do either of you have any suggestions? I'm thinking the more performant approach would be better, just wrapping each component in a simple arrow function instead of trying to use |
727be70
to
987147a
Compare
This issue is due to the Redux `connect` wrapper around `<App/>`. `connect` diffs changes in regular props to know when to update the component, but doesn't check context props like `location`. See https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/blocked-updates.md.
987147a
to
1c2e417
Compare
@tech4him1 is your last comment still an issue? That would make this WIP, just checking status. |
<Switch> | ||
<Route exact path='/' component={DashboardPage} /> | ||
<Route exact path="/collections/:name" component={CollectionPage} /> | ||
<Route path="/collections/:name/entries/new" render={(props) => (<EntryPage {...props} newRecord={true}/>)} /> |
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.
One thing I'm not quite sure about is whether this is the best way to pass newRecord
through here.
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.
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.
You could clean it up a little: render={props => <EntryPage {...props} newRecord />}
I think the boolean prop will work that way, right?
@erquhart @Benaiah I've just been reading through this: https://css-tricks.com/react-router-4/#article-header-id-4. |
@tech4him1 based on our conversation in Gitter (pasted below for future reference), I think that's fine in some situations, but only where there's a clear advantage to doing so. Either way, I'd like to review and merge this as is as we discussed in Gitter.
|
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.
LGTM - code seems fine and manually testing the routing didn't bring up any regressions. 404s aren't working when they're a valid route for a nonexistent resource, but that's not a regression.
4af5a1c
to
1c2e417
Compare
* Upgrade to React Router v4 * Fix pages not change when the URL was changed. This issue is due to the Redux `connect` wrapper around `<App/>`. `connect` diffs changes in regular props to know when to update the component, but doesn't check context props like `location`. See https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/blocked-updates.md. * Update to new `history` methods.
- Summary
Close #413.
Upgrade React Router (and
react-router-redux
) to version 4.- Test plan
Manually test routing (unless someone else has a better testing method).
- Description for the changelog
Upgrade to React Router v4.
- A picture of a cute animal (not mandatory but encouraged)