react-router-component
react-router-component copied to clipboard
navigation.replace should default to true if path is current path
Currently, using replaceState
is always opt-in (i.e. it defaults to false
):
if (!navigation.isPopState) {
if (navigation.replace) {
this.replaceState(path, navigation);
} else {
this.pushState(path, navigation);
}
}
I think we should change this so that it defaults to true if the paths are the same. In other words, something like this:
var replace = navigation.replace == null ? normalize(path) === normalize(this.getPath()) : navigation.replace;
(The ==
is used intentionally here so as to also catch undefined
.)
This makes a lot of sense if the path remains the same but the query parameters are changed. Pull request #43 might do this, although after a quick skim of the code I'm not sure.