@fatgy/use-navigation-lock
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

useNavigationLock

Navigation lock hook for next.js

Install

npm install @fatgy/use-navigation-lock

Usage

import {useNavigationLock} from '@fatgy/use-navigation-lock';

useNavigationLock(true);
//=> Show confirm dialog

useNavigationLock(false);
//=> Not show confirm dialog

API

useNavigationLock(isEnabled, warningText, onConfirm)

isEnabled

Type: boolean | undefined

Default: false

warningText

Type: string | undefined

Default: Are you sure you want to leave this page? You have unsaved changes. Do you want to leave?

onConfirm

Type: function | undefined

Readme

Keywords

none

Package Sidebar

Install

npm i @fatgy/use-navigation-lock

Weekly Downloads

51

Version

2.0.0

License

MIT

Unpacked Size

5.27 kB

Total Files

5

Last publish

Collaborators

  • fatgy