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

A replacement component for the react-router ``. Allows for more flexible dialogs.

  • 1.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
58K
increased by5.83%
Maintainers
1
Weekly downloads
 
Created
Source

React Router

Table of Contents

Overview
Example Usage

Overview

A replacement component for the react-router <Prompt/>. Allows for more flexible dialogs.

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.

Motivation: https://github.com/ReactTraining/react-router/issues/4635

Adapted from: https://gist.github.com/bummzack/a586533607ece482475e0c211790dd50

Example Usage

<NavigationPrompt when={this.state.shouldConfirmNavigation}>
  {({onConfirm, onCancel}) => (
    <Modal show={true}>
      <div>
        <p>Do you really want to leave?</p>
        <button onClick={onCancel}>Cancel</button>
        <button onClick={onConfirm}>Ok</button>
      </div>
    </Modal>
  )}
</NavigationPrompt>
<NavigationPrompt when={this.state.shouldConfirmNavigation}>
  {({onConfirm, onCancel}) => (
    <div>
      <p>Do you really want to leave?</p>
      <button onClick={onCancel}>Cancel</button>
      <button onClick={onConfirm}>Ok</button>
    </div>
  )}
</NavigationPrompt>

Keywords

FAQs

Package last updated on 25 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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