react-router-component icon indicating copy to clipboard operation
react-router-component copied to clipboard

navigation.replace should default to true if path is current path

Open matthewwithanm opened this issue 10 years ago • 1 comments

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.)

matthewwithanm avatar Apr 21 '14 15:04 matthewwithanm

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.

jamwaffles avatar Nov 19 '14 07:11 jamwaffles