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

Global transition event handler? #1764

Closed
benvinegar opened this issue Aug 25, 2015 · 2 comments
Closed

Global transition event handler? #1764

benvinegar opened this issue Aug 25, 2015 · 2 comments

Comments

@benvinegar
Copy link
Contributor

Something like:

var router = require('react-router');

router.onTransition(function (transition, component) {
  if (sessionExpired)
    transition.redirect('/login');
});

The closest example of achieving this is from the react-router auth example, which uses inheritance to reuse a willTransitionFrom declaration on every routed component.

@stremlenye
Copy link

In the beta-x versions there are onEnter hook which could be applied for any Route component, for example:

<Route component={ApplicationContainer} onEnter={requireAuth}>
  <Route componen={HomePage} path="/home" /></Route>

Thats probably what you want.
http://rackt.github.io/react-router/tags/v1.0.0-beta3.html#Route

@ryanflorence
Copy link
Member

in v0.13.3 your change handler is just Router.run(routes, changeHandler.

On master its <Router onUpdate={fn}/>

@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants