react-router-navigation-prompt
Advanced tools
Comparing version 1.6.3 to 1.6.4
@@ -124,2 +124,3 @@ module.exports = | ||
/*:: _prevUserAction: string; */ | ||
/*:: _isMounted: bool; */ | ||
@@ -136,2 +137,6 @@ function NavigationPrompt(props) { | ||
// This component could be used from inside a page, and therefore could be | ||
// mounted/unmounted when the route changes. | ||
_this._isMounted = true; | ||
_this.block = _this.block.bind(_this); | ||
@@ -167,2 +172,3 @@ _this.onBeforeUnload = _this.onBeforeUnload.bind(_this); | ||
value: function componentWillUnmount() { | ||
this._isMounted = false; | ||
if (this._prevUserAction === 'CONFIRM' && typeof this.props.afterConfirm === 'function') { | ||
@@ -208,7 +214,10 @@ this._prevUserAction = ''; | ||
// $FlowFixMe history.replace()'s type expects LocationShape even though it works with Location. | ||
history[action](nextLocation); | ||
history[action](nextLocation); // could unmount at this point | ||
this._prevUserAction = 'CONFIRM'; | ||
this.setState(_extends({}, initState, { | ||
unblock: this.props.history.block(this.block) | ||
})); // FIXME? Does history.listen need to be used instead, for async? | ||
if (this._isMounted) { | ||
// Just in case we unmounted on the route change | ||
this.setState(_extends({}, initState, { | ||
unblock: this.props.history.block(this.block) | ||
})); // FIXME? Does history.listen need to be used instead, for async? | ||
} | ||
} | ||
@@ -215,0 +224,0 @@ }, { |
{ | ||
"name": "react-router-navigation-prompt", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"description": "A replacement component for the react-router `<Prompt/>`. Allows for more flexible dialogs.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -51,2 +51,3 @@ /* @flow */ | ||
/*:: _prevUserAction: string; */ | ||
/*:: _isMounted: bool; */ | ||
@@ -61,2 +62,6 @@ constructor(props) { | ||
// This component could be used from inside a page, and therefore could be | ||
// mounted/unmounted when the route changes. | ||
this._isMounted = true; | ||
(this:Object).block = this.block.bind(this); | ||
@@ -87,2 +92,3 @@ (this:Object).onBeforeUnload = this.onBeforeUnload.bind(this); | ||
componentWillUnmount() { | ||
this._isMounted = false; | ||
if (this._prevUserAction === 'CONFIRM' && typeof this.props.afterConfirm === 'function') { | ||
@@ -122,8 +128,10 @@ this._prevUserAction = ''; | ||
// $FlowFixMe history.replace()'s type expects LocationShape even though it works with Location. | ||
history[action](nextLocation); | ||
history[action](nextLocation); // could unmount at this point | ||
this._prevUserAction = 'CONFIRM'; | ||
this.setState({ | ||
...initState, | ||
unblock: this.props.history.block(this.block) | ||
}); // FIXME? Does history.listen need to be used instead, for async? | ||
if (this._isMounted) { // Just in case we unmounted on the route change | ||
this.setState({ | ||
...initState, | ||
unblock: this.props.history.block(this.block) | ||
}); // FIXME? Does history.listen need to be used instead, for async? | ||
} | ||
} | ||
@@ -130,0 +138,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
444328
38
5953