1.0.0 • Published 4 years ago

@am-hooks/use-beforeunload v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

usePreventLeave

유저가 변경 사항을 저장하지 않고 페이지를 벗어나가길 원할 때 알림 메시지 표시

Installation

yarn

yarn add @am-hooks/use-preventLeave

npm

npm i @am-hooks/use-preventLeave

Usage

import usePreventLeave from "@am-hooks/use-preventLeave";

const App = () => {
  const { enablePrevent, disablePrevent } = usePreventLeave();
  
  return (
    <>
      <button onClick={enablePrevent}>protect</button>
      <button onClick={disablePrevent}>unprotect</button> 
    </>
  )
}