This repository was archived by the owner on Oct 26, 2018. It is now read-only.
This repository was archived by the owner on Oct 26, 2018. It is now read-only.
setRouteLeaveHook double called #160
Closed

Description
I'm having this issue when using redux simple router with setRouteLeaveHook on the context my routerWillLeave callback executes twice.
class MyComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.routerWillLeaveCallCount = 0;
}
componentDidMount() {
this.context.router.setRouteLeaveHook(this.props.route, this.routerWillLeave.bind(this));
}
routerWillLeave(route) {
console.log(route.action);
if (this.hasUnsavedData() && this.routerWillLeaveEvenCallCount()) {
return 'You have an unsaved data, are you sure you want to leave?';
}
}
routerWillLeaveEvenCallCount() {
return this.routerWillLeaveCallCount++ % 2 === 0;
}
I see PUSH PUSH in my console log.
I cloned this repo https://github.com/freeqaz/redux-simple-router-example.git and upgraded it to react-router 2.0.0-rc4 and redux-simple-router 1.0.2 and confirmed it had the same issue.
When I run the example https://github.com/rackt/react-router/tree/master/examples/transitions it only fires once.
Metadata
Metadata
Assignees
Labels
No labels