Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-router-navigation-prompt

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-router-navigation-prompt - npm Package Compare versions

Comparing version 1.6.3 to 1.6.4

test/src/components/issues/Issue30.js

17

es/index.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc