inferno icon indicating copy to clipboard operation
inferno copied to clipboard

inferno-router: catch Hash history cannot PUSH the same path;

Open sprlwrksAprilmintacpineda opened this issue 6 years ago • 3 comments

Issue Template

Is there a way to catch this and do something?

Inferno Metadata

macOS Safari / Chrome / Firefox / [email protected]

Hi can you give concerete example what you are trying to do please

Havunen avatar Jun 25 '18 19:06 Havunen

@Havunen when the user clicks on a <Link to="/someurl">Go</Link> and he's already on that URL, a warning will show on the console. What I want to do is do state changes on the parent of the Route component.

class App extends Component {
  state = {
    // some state
  }

  handler = () => {
    // handle user already on that path.
  }

  render = () => (
    <Parent>
      <HashRouter>
        <Route onComponentAlreadyHere={this.handler} path="someurl" component={Page} />
      </HashRouter>
    </Parent>
  );
}

aprilmintacpineda avatar Jun 26 '18 02:06 aprilmintacpineda

I'm not very familiar with the Router code base, maybe @nightwolfz @LukeSheard knows better. Meanwhile you can try to check this out yourself?

Havunen avatar Jun 26 '18 16:06 Havunen