Socket
Socket
Sign inDemoInstall

react-router-navigation-prompt

Package Overview
Dependencies
8
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.8.15 to 1.9.0

4

CHANGELOG.md

@@ -7,2 +7,6 @@ # Changelog

## [1.9.0] - 2021-09-18
### Added
- expose history action to this.props.when function. Read more: https://github.com/ZacharyRSmith/react-router-navigation-prompt/issues/78
## [1.8.15] - 2021-06-21

@@ -9,0 +13,0 @@ ### Changed

6

es/index.js

@@ -185,3 +185,3 @@ module.exports =

value: function block(nextLocation, action) {
var result = this.when(nextLocation);
var result = this.when(nextLocation, action);
if (result) {

@@ -275,5 +275,5 @@ this.setState({

key: 'when',
value: function when(nextLocation) {
value: function when(nextLocation, action) {
if (typeof this.props.when === 'function') {
return this.props.when(this.props.location, nextLocation);
return this.props.when(this.props.location, nextLocation, action);
} else {

@@ -280,0 +280,0 @@ return this.props.when;

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

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

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

**Note: If you pass a function to props.when, then make sure to check if nextLocation is defined before trying to use it.**
**Note: If you pass a function to `props.when`, then make sure to check if `nextLocation` and `action` are defined before trying to use them.**

@@ -78,3 +78,3 @@ **Note: Just like react-router's `<Prompt/>`, this component does not work with multiple `BrowserHistory`s: https://github.com/ZacharyRSmith/react-router-navigation-prompt/issues/77 **

// Confirm navigation if going to a path that does not start with current path:
when={(crntLocation, nextLocation) =>
when={(crntLocation, nextLocation, _action) =>
!nextLocation || !nextLocation.pathname.startsWith(crntLocation.pathname)

@@ -110,3 +110,3 @@ }

- renderIfNotActive: bool,
- when: bool | (Location, ?Location) => bool,
- when: bool | (Location, ?Location, ?HistoryAction) => bool,
- disableNative: bool,

@@ -113,0 +113,0 @@ // Added by react-router:

@@ -16,3 +16,3 @@ /* @flow */

renderIfNotActive?: bool,
when: bool | (Location, ?Location) => bool,
when: bool | (Location, ?Location, ?HistoryAction) => bool,
disableNative?: bool,

@@ -106,3 +106,3 @@ allowGoBack?: bool,

block(nextLocation, action) {
const result = this.when(nextLocation);
const result = this.when(nextLocation, action);
if (result) {

@@ -181,5 +181,5 @@ this.setState({

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

@@ -186,0 +186,0 @@ return this.props.when;

@@ -13,3 +13,3 @@ import * as React from 'react';

children: (data: ChildData) => React.ReactNode;
when: boolean | ((currentLocation: H.Location, nextLocation?: H.Location) => boolean);
when: boolean | ((currentLocation: H.Location, nextLocation?: H.Location, action?: H.Action) => boolean);
afterCancel?: () => void;

@@ -40,3 +40,3 @@ afterConfirm?: () => void;

onBeforeUnload(e: any): string
when(nextLocation?: H.Location): boolean;
when(nextLocation?: H.Location, action?: H.Action): boolean;
}

@@ -43,0 +43,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc