react-usepopstate
v1.0.1
Published
React window event listener popstate
Downloads
23
Maintainers
Readme
Installation
Using npm:
$ npm install --save react-usepopstate
Using yarn:
$ yarn add react-usepopstate
Quick Start
import React from 'react';
import usePopstate from 'react-usepopstate';
const render = () => {
const { isBackButtonClicked } = usePopstate({
isPrompt: true,
alertDescription: 'Confirm back',
callback: () => {
alert('BACK')
},
})
return (
<>
<div>Hello React!</div>
</>
);
}
Documentation
const { isBackButtonClicked } = usePopstate({ isPrompt, alertDescription, callback })
Parameters object
alertDescription
{String
} Confirm prompt descriptioncallback
{Function
} Callback functionisPrompt
{Booleen
} Use confirm propmt default : false
Return value
isBackButtonClicked
{Booleen
} Back status
Contributing
Feel free to submit any issues or pull requests.
License
MIT