Skip to content

Instantly share code, notes, and snippets.

@erosenberg
Created June 8, 2015 03:50
Show Gist options
  • Save erosenberg/a34314893bdaae919e7e to your computer and use it in GitHub Desktop.
Save erosenberg/a34314893bdaae919e7e to your computer and use it in GitHub Desktop.
TransitionHook Class
import { object } from 'react';
'use strict';
class TransitionHook extends React.Component {
constructor(props) {
super(props);
this.router = this.context.router;
}
componentDidMount () {
this.router.addTransitionHook(this.routerWillLeave);
}
componentWillUnmount () {
this.router.removeTransitionHook(this.routerWillLeave);
}
}
export default TransitionHook;
TransitionHook.contextTypes = {
object: React.PropTypes.func.isRequired
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment