Skip to content

Commit d7832db

Browse files
committed
fix: reset form and store state when navigating away from upload page
1 parent 3bda4b8 commit d7832db

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/frontend/src/modules/song-upload/components/client/context/UploadSong.context.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,14 @@ export const UploadSongProvider = ({
321321
};
322322
}, [formMethods.formState.isDirty, isUploadComplete]);
323323

324+
// Reset form and store state when component unmounts
325+
useEffect(() => {
326+
return () => {
327+
formMethods.reset();
328+
store.reset();
329+
};
330+
}, []);
331+
324332
const formContextValue: UploadSongFormContextType = {
325333
formMethods,
326334
register,

0 commit comments

Comments
 (0)