Skip to content

Commit

Permalink
Revalidate after show notification
Browse files Browse the repository at this point in the history
 (#105)
  • Loading branch information
kimurash committed Oct 31, 2024
1 parent 5c6ed03 commit 892b134
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/app/routes/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -77,6 +82,7 @@ const Home = () => {

const [user, setUser] = useAtom(userAtom);
const navigation = useNavigation();
const revalidator = useRevalidator();

useEffect(() => {
if (navigation.state === 'idle') {
Expand All @@ -100,12 +106,14 @@ const Home = () => {
useEffect(() => {
if (success) {
successNotification(success);
revalidator.revalidate();
}
}, [success]);

useEffect(() => {
if (error) {
errorNotification(error);
revalidator.revalidate();
}
}, [error]);

Expand Down

0 comments on commit 892b134

Please sign in to comment.