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.0.1 to 1.1.0

2

package.json
{
"name": "react-router-navigation-prompt",
"version": "1.0.1",
"version": "1.1.0",
"description": "A replacement component for the react-router `<Prompt/>`. Allows for more flexible dialogs.",

@@ -5,0 +5,0 @@ "scripts": {

@@ -13,3 +13,3 @@ # React Router <NavigationPrompt/>

IMPORTANT: Currently, this does not confirm navigation to another website.
Note: When NavigationPrompt.props.when is truthy, then confirmation is requested when navigating away. Usually, browsers handle the UX themselves, leading to vanilla alert boxes. Also, many browsers require users to interact with your site before confirming navigation away.

@@ -16,0 +16,0 @@ Motivation: https://github.com/ReactTraining/react-router/issues/4635

@@ -26,3 +26,3 @@ import React from 'react';

super(props);
this.state = {action: null, nextLocation: null, isActive: false};
this.onBeforeUnload = this.onBeforeUnload.bind(this);
this.onCancel = this.onCancel.bind(this);

@@ -40,6 +40,12 @@ this.onConfirm = this.onConfirm.bind(this);

});
this.state = {action: null, nextLocation: null, isActive: false};
}
componentDidMount() {
window.addEventListener('beforeunload', this.onBeforeUnload);
}
componentWillUnmount() {
this.unblock();
window.removeEventListener('beforeunload', this.onBeforeUnload);
}

@@ -70,2 +76,9 @@

onBeforeUnload(e) {
if (!this.props.when) return;
const msg = 'Do you want to leave this site?\n\nChanges you made may not be saved.';
e.returnValue = msg;
return msg;
}
unblock() {

@@ -72,0 +85,0 @@ // Init in constructor().

Sorry, the diff of this file is too big to display

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