Skip to content

Commit 67f9f7a

Browse files
committed
reload confirmation added
1 parent f0b48bc commit 67f9f7a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/App.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useReducer } from 'react';
1+
import React, { useEffect, useReducer } from 'react';
22
import './App.css';
33
import ReactTooltip from 'react-tooltip';
44
import GraphWorkspace from './GraphWorkspace';
@@ -15,6 +15,16 @@ import FileEditModal from './component/modals/FileEdit';
1515

1616
const app = () => {
1717
const [superState, dispatcher] = useReducer(reducer, initialState);
18+
useEffect(() => {
19+
const handleBeforeUnload = (e) => {
20+
e.returnValue = 'Are you sure you want to leave this page?';
21+
return 'Are you sure you want to leave this page?';
22+
};
23+
window.onbeforeunload = handleBeforeUnload;
24+
return () => {
25+
window.onbeforeunload = null;
26+
};
27+
}, []);
1828
return (
1929
<div className="container">
2030
<ProjectDetails superState={superState} dispatcher={dispatcher} />

0 commit comments

Comments
 (0)