From 892b13430e7602d313b31c22ade664617b0d62a6 Mon Sep 17 00:00:00 2001 From: shunsei Date: Thu, 31 Oct 2024 15:07:24 +0900 Subject: [PATCH] Revalidate after show notification (#105) --- frontend/app/routes/home.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/app/routes/home.tsx b/frontend/app/routes/home.tsx index 469f90bd..8180c61a 100644 --- a/frontend/app/routes/home.tsx +++ b/frontend/app/routes/home.tsx @@ -5,7 +5,12 @@ import { LoaderFunctionArgs, redirect, } from '@remix-run/cloudflare'; -import { Outlet, useLoaderData, useNavigation } from '@remix-run/react'; +import { + Outlet, + useLoaderData, + useNavigation, + useRevalidator, +} from '@remix-run/react'; import { getUser, logout } from 'client/client'; import { useAtom } from 'jotai'; import { useEffect } from 'react'; @@ -77,6 +82,7 @@ const Home = () => { const [user, setUser] = useAtom(userAtom); const navigation = useNavigation(); + const revalidator = useRevalidator(); useEffect(() => { if (navigation.state === 'idle') { @@ -100,12 +106,14 @@ const Home = () => { useEffect(() => { if (success) { successNotification(success); + revalidator.revalidate(); } }, [success]); useEffect(() => { if (error) { errorNotification(error); + revalidator.revalidate(); } }, [error]);