diff --git a/src/hook/useJobQuery.ts b/src/hook/useJobQuery.ts index 73802f7..722dbda 100644 --- a/src/hook/useJobQuery.ts +++ b/src/hook/useJobQuery.ts @@ -236,5 +236,8 @@ export const useEachTodosQuery = (todoGroupId: number) => { return useQuery({ queryKey: ['EachTodos', todoGroupId], queryFn: () => EachTodos(todoGroupId), + retry: false, // 404 등 에러시 불필요한 재시도 방지 (체감 속도 향상) + refetchOnWindowFocus: false, + staleTime: 60 * 1000, }); }; diff --git a/src/pages/otherTodoList/OtherTodoListPage.tsx b/src/pages/otherTodoList/OtherTodoListPage.tsx index 4e81a42..eee4912 100644 --- a/src/pages/otherTodoList/OtherTodoListPage.tsx +++ b/src/pages/otherTodoList/OtherTodoListPage.tsx @@ -28,6 +28,13 @@ const OtherTodoListPage = () => { isError, } = useEachTodosQuery(Number(todoGroupId)); + // 404 등 조회 에러 발생 시 내 할일로 리다이렉트 + useEffect(() => { + if (isError) { + navigate('/mytodo/list', { replace: true }); + } + }, [isError, navigate]); + if (isLoading) { return (
@@ -36,9 +43,7 @@ const OtherTodoListPage = () => { ); } - if (isError) { - return
에러가 발생했습니다.
; - } + // isError 시에는 상단 useEffect에서 리다이렉트 처리 if (!eachTodos) return (