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.4.0 to 1.5.0

2

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

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

/* @flow */
import React from 'react';
import {withRouter} from 'react-router-dom';
import type {HistoryAction, Location, RouterHistory} from 'react-router-dom';
import type {HistoryAction, Location, Match, RouterHistory} from 'react-router-dom';

@@ -12,5 +12,7 @@ declare type PropsT = {

children: (data: {isActive: bool, onCancel: Function, onConfirm: Function}) => React$Element<*>,
match: Match,
history: RouterHistory,
location: Location,
renderIfNotActive: bool,
when: bool
when: bool | (Location, ?Location) => bool
};

@@ -50,2 +52,3 @@ declare type StateT = {

(this:Object).onConfirm = this.onConfirm.bind(this);
(this:Object).when = this.when.bind(this);

@@ -65,3 +68,3 @@ this.state = {...initState, unblock: props.history.block(this.block)};

block(nextLocation, action) {
if (this.props.when) {
if (this.when(nextLocation)) {
this.setState({

@@ -73,3 +76,3 @@ action,

}
return !this.props.when;
return !this.when(nextLocation);
}

@@ -116,3 +119,3 @@

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

@@ -123,2 +126,10 @@ e.returnValue = msg;

when(nextLocation?: Location) {
if (typeof this.props.when === 'function') {
return this.props.when(this.props.location, nextLocation);
} else {
return this.props.when;
}
}
render() {

@@ -125,0 +136,0 @@ if (!this.state.isActive && !this.props.renderIfNotActive) return null;

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