Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make popstate behave #60

Open
yoshuawuyts opened this issue Jun 12, 2014 · 0 comments
Open

Make popstate behave #60

yoshuawuyts opened this issue Jun 12, 2014 · 0 comments

Comments

@yoshuawuyts
Copy link

It appears that react-router-component listens to onpopstate() and triggers itself, causing a conflict with my current setup.

When clicking a navigation element in my application, the path store gets updated and through a change-listener my router triggers a re-render. If I hit the back button, I'd like to update the path store with window.location.pathname, and through a change-listener trigger a re-render on my router.

How can I make react-router-component stop triggering on onpopstate() events?

edit: I want to make this work:

function componentDidMount() {
  // update the state with the new url when the store updates
  pathStore.on('update', updateUrl.bind(this));
  // listen to changes to 'pop state' and update the store accordingly
  window.onpopstate = function() {
    dispatcher.dispatch('path_update', window.location.pathname);
  };
}
yoshuawuyts added a commit to yoshuawuyts/versity-legacy that referenced this issue Jun 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant