Skip to content

Commit 29a67a9

Browse files
committed
feat:글 작성 페이지 네비게이션 가드 테스트
1 parent 6227d93 commit 29a67a9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/pages/Write/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ const WritePage = () => {
4242
};
4343
}, [resetWrite]);
4444

45+
useEffect(() => {
46+
const navigationGuard = (e: BeforeUnloadEvent) => {
47+
e.preventDefault();
48+
};
49+
window.addEventListener('beforeunload', navigationGuard);
50+
51+
return () => {
52+
window.removeEventListener('beforeunload', navigationGuard);
53+
};
54+
}, []);
55+
4556
const wrapStyle = twMerge(
4657
'relative p-5 w-full grow flex flex-col',
4758
`${step === 'edit' && PAPER_TYPE_OBJ[paperType]}`,

0 commit comments

Comments
 (0)