Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor-fe: Tanstack Query 데이터 캐싱 정책 변경 #947

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/src/pages/ErrorPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useQueryClient } from '@tanstack/react-query';
import ApiError from '@api/ApiError';
import Button from '@components/_common/atoms/Button';
import { ButtonColor } from '@components/_common/atoms/Button/style';
Expand Down Expand Up @@ -106,6 +107,7 @@ export default function ErrorPage() {
const error = useRouteError();
const navigate = useNavigate();
const { clearClubId } = useClubId();
const queryClient = useQueryClient();

let status;

Expand All @@ -114,6 +116,7 @@ export default function ErrorPage() {
} else if (error instanceof ApiError) {
status = error.statusCode;
if (status === 401) {
queryClient.clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcTime 설정보다 이게 더 범용성 있는 로직이기 때문에 적절한 대처 같아요.👍
어짜피 401 에러가 발생하면 다시 로그인을 해야 하므로 모든 쿼리의 캐시를 지우는 것도 무리 없어 보입니다.

clearClubId();
}
}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/router/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export default function AppRouter() {
queries: {
throwOnError: true,
retry: 0,
gcTime: 0,
},
mutations: {
onError: (error) => {
Expand Down
Loading