Skip to content

Commit

Permalink
fix(qa-modal): 패널 로더 데이터가 undefined인 경우 분기한다 (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
leegwae authored and github-actions[bot] committed Sep 6, 2023
1 parent 62b2265 commit ca9f2f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/panel/QAModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function QAModal({
const userId = useUserStore((state) => state.id);
// [NOTE] 질문과 답변 모달은 패널 페이지에서만 사용되므로
// 패널 페이지 로더가 반환하는 데이터가 null이 아님이 보장된다
const { author, ...panel } = useRouteLoaderData('panel') as Panel;
const panelLoaderData = useRouteLoaderData('panel') as Panel;
const now = useCurrentDate();
const answersQuery = useAnswersQuery(questionId);

Expand Down Expand Up @@ -108,6 +108,10 @@ export function QAModal({
},
});

if (panelLoaderData === undefined) return <></>;

const { author, ...panel } = panelLoaderData;

// TODO: Fallback UI 제공하기
if (answersQuery.isLoading) return <div>loading</div>;
if (answersQuery.isError) return <div>error</div>;
Expand Down

0 comments on commit ca9f2f4

Please sign in to comment.