rerender on props.url change#332
Conversation
| return props.url!==this.props.url || props.onChange!==this.props.onChange; | ||
| } | ||
|
|
||
| componentWillReceiveProps(props) { |
There was a problem hiding this comment.
I think we can merge this with shouldComponentUpdate above.
shouldComponentUpdate(props) {
if (props.url && props.url!==this.state.url) this.routeTo(props.url);
return !props.static || props.url!=this.props.url || props.onChange!=this.props.onChange;
}| } | ||
|
|
||
| componentWillReceiveProps(props) { | ||
| if (props.url && props.url!==this.state.url) this.routeTo(props.url) && setUrl(props.url); |
There was a problem hiding this comment.
Passing a new URL to <Router> should not call setUrl(), since doing so will change all other Routers on the page.
|
Sorry for the super long delay in reviewing this @halcaponey! Just a few things I think we can address to get this merged. |
|
Update looks good. Only thing I want to check is if this is triggering a double-render when changing the URL prop. Ideally we'd propagate the state without forcing a second render, since the router is already being re-rendered with the new URL as a prop. |
|
The problem comes from What is the static prop used for ? It's only called in shouldComponentUpdate.
|
resolves #330