Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class Router extends Component {
return props.url!==this.props.url || props.onChange!==this.props.onChange;
}

componentWillReceiveProps(props) {
Copy link
Member

Choose a reason for hiding this comment

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

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;
	}

if (props.url && props.url!==this.state.url) this.routeTo(props.url) && setUrl(props.url);
Copy link
Member

Choose a reason for hiding this comment

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

Passing a new URL to <Router> should not call setUrl(), since doing so will change all other Routers on the page.

}

/** Check if the given URL can be matched against any children */
canRoute(url) {
const children = toChildArray(this.props.children);
Expand Down