mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 02:06:34 +02:00
🐛 Clear session store when leaving new page (#871)
This commit is contained in:
parent
c89a3b939c
commit
2c3602cdfa
1 changed files with 5 additions and 2 deletions
|
@ -12,6 +12,7 @@ import { useRouter } from "next/router";
|
|||
import React from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import useFormPersist from "react-hook-form-persist";
|
||||
import { useUnmount } from "react-use";
|
||||
|
||||
import { PollSettingsForm } from "@/components/forms/poll-settings";
|
||||
import { Trans } from "@/components/trans";
|
||||
|
@ -51,11 +52,13 @@ export const CreatePoll: React.FunctionComponent = () => {
|
|||
},
|
||||
});
|
||||
|
||||
useFormPersist("new-poll", {
|
||||
const { clear } = useFormPersist("new-poll", {
|
||||
watch: form.watch,
|
||||
setValue: form.setValue,
|
||||
});
|
||||
|
||||
useUnmount(clear);
|
||||
|
||||
const posthog = usePostHog();
|
||||
const queryClient = trpc.useContext();
|
||||
const createPoll = trpc.polls.create.useMutation();
|
||||
|
@ -90,7 +93,7 @@ export const CreatePoll: React.FunctionComponent = () => {
|
|||
optionsView: formData?.view,
|
||||
});
|
||||
queryClient.polls.list.invalidate();
|
||||
router.replace(`/poll/${res.id}`);
|
||||
router.push(`/poll/${res.id}`);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue