security.txt + bugfixes
This commit is contained in:
16
react/shared/hooks/before-unload.js
Normal file
16
react/shared/hooks/before-unload.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import {useCallback, useEffect} from "react";
|
||||
|
||||
export default function useBeforeUnload(modified) {
|
||||
|
||||
const capture = useCallback((event) => {
|
||||
if (modified) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}, [modified]);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("beforeunload", capture, {capture: true});
|
||||
return () => window.removeEventListener("beforeunload", capture, { capture: true });
|
||||
}, []);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user