{"_id":"@ej-hooks/use-prevent-leave","_rev":"1-805c1e28cb2d469a5b507701a7d5267c","name":"@ej-hooks/use-prevent-leave","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ej-hooks/use-prevent-leave","version":"1.0.0","description":"React Hook to prompt the user for confirmation before leaving the page. Useful when changes haven't been saved.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/eunjinfizz/react-hooks.git"},"keywords":["react","hooks","prevent-leave","react-hooks"],"author":{"name":"Eunjin Kwon","email":"eunjinfizz@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/eunjinfizz/react-hooks/issues"},"homepage":"https://github.com/eunjinfizz/react-hooks#readme","peerDependencies":{"react":"^17.0.2","react-dom":"^17.0.2"},"_id":"@ej-hooks/use-prevent-leave@1.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-bxGc0/Hm9/u3bEmnRhU0xhQ16adQdwAh+UWsQ4jwZ+M4m6JAKeQ8k4Sg2xzs9OkyGzDrVzqn1A2Zhi5sCTJWgg==","shasum":"c1b6eda7bb8fab29ddc4bde7b2923e25603161c0","tarball":"https://registry.npmjs.org/@ej-hooks/use-prevent-leave/-/use-prevent-leave-1.0.0.tgz","fileCount":4,"unpackedSize":2262,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhD9FyCRA9TVsSAnZWagAAtb0P/iWb1Zjr2ThLgASuR/p9\nzGAd617TVw6SBFIlyFpDnPMndqcqWN6qN6MKlOG3Y7k3lgk7mqEIsr/8leGl\nOOnOrSiCfMbpPgmYCtdyjzCI0zDIJa+S1XaaLrwBwwiNM8zUnjGIjLuBRjFh\nCcHImuXHDCQSc5KFR/3h4udeSkbMsvXaZYDFjwG2zjDma1T+rel/HyxdpuBB\noKx58ZXt1jyRlfbt8vEHhAYwjWoO7YFbU/on1dLmR+9S3XPLaO36huexRaI7\nOFQve4S64DDjAR/A27szSArRlSVjfwpqzdwn2eodo8m5XR45KsZLpDGrfQev\niz2NaQwqIQWB2a9PYrs/du327xvb4ZMGfdeWJvvBl6dBimO4QoB6nQRWH9Kz\nIG1rFUKv8TPq5Yo7oYPZnLdAARgPr/B1SDnlIEPZgpwoynGnyzUy0A/lMx3e\nWZi0Bxur4mKXroFjiAasvKaj31lkV6J9LOW1dFO66HWZoWoXggPn/6KjsAPU\n/dAUZKexKY+vIfBFQt4OhSHmixfEGYBeyd8q9crSz5lGiawgiBloyt/HYs7D\nMu/lPjSVSWpSzMpS8RliSG0w4Y4ZDTGr5XGwnTnrsfaNlPT8VNJfC2vCoHgg\nvxFVyh9H/CI0esRZAo3ss4Hke3taiQeCWsW4sJkr4xWkPp1Ki3wrB/XpJZ0B\nYT1d\r\n=1cdR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA1JiUbIgYcnHdN25G+5FPJHY+MV4nOBqCgoU4I+t0MIAiEA8uFRUqyGO7GjcyeQ0Z/bRMPnWruJccj4ek0Pyxh1CtM="}]},"_npmUser":{"name":"eunjinfizz","email":"eunjinfizz@gmail.com"},"directories":{},"maintainers":[{"name":"eunjinfizz","email":"eunjinfizz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-prevent-leave_1.0.0_1628426609858_0.4765769070293129"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-08T12:43:29.796Z","1.0.0":"2021-08-08T12:43:30.045Z","modified":"2022-04-05T07:01:06.986Z"},"maintainers":[{"name":"eunjinfizz","email":"eunjinfizz@gmail.com"}],"description":"React Hook to prompt the user for confirmation before leaving the page. Useful when changes haven't been saved.","homepage":"https://github.com/eunjinfizz/react-hooks#readme","keywords":["react","hooks","prevent-leave","react-hooks"],"repository":{"type":"git","url":"git+https://github.com/eunjinfizz/react-hooks.git"},"author":{"name":"Eunjin Kwon","email":"eunjinfizz@gmail.com"},"bugs":{"url":"https://github.com/eunjinfizz/react-hooks/issues"},"license":"MIT","readme":"# @ej-hooks/use-prevent-leave\r\n\r\nReact Hook to prompt the user for confirmation before leaving the page. Useful when changes haven't been saved.\r\n\r\n## Installation\r\n\r\n#### yarn\r\n\r\n`yarn add @ej-hooks/use-prevent-leave`\r\n\r\n#### npm\r\n\r\n`npm i @ej-hooks/use-prevent-leave`\r\n\r\n## Usage\r\n\r\n```js\r\nimport React from 'react';\r\nimport usePreventLeave from '@ej-hooks/use-prevent-leave';\r\nfunction App() {\r\n  const { enablePrevent, disablePrevent } = usePreventLeave();\r\n  const saveChanges = async () => {\r\n    enablePrevent();\r\n    await sendToApi();\r\n    disablePrevent();\r\n  };\r\n  return <button onClick={saveChanges}>Save changes</button>;\r\n}\r\n```\r\n\r\n### Return\r\n\r\n| Return value | Type   | Description                                                                                                                     |\r\n| ------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------- |\r\n| Functions    | Object | A object containing functions `enablePrevent` and `disablePrevent`, use this functions to enable/disable the leaving prevention |\r\n","readmeFilename":"README.md"}