Skip to content

Commit

Permalink
#12 Fix retry to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
limyeonsang committed Jul 11, 2022
1 parent e805ea5 commit 36a92d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 8 additions & 2 deletions views/myPage/AnswerVideos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ const AnswerVideos = () => {
const answerRes = useInfiniteQuery(
[queryKey.myAnswer],
async ({ pageParam = 1 }) => {
const res = (await getMyAnswerList(pageParam, 10)).data.data
const res = (await getMyAnswerList(pageParam, 10)).data.data;

return { page: pageParam, data: res };
},
{
getNextPageParam: (lastPage) => lastPage.page + 1,
retry: 0,
},
);

Expand All @@ -27,13 +28,17 @@ const AnswerVideos = () => {
);

useEffect(() => {
if (inView) {
if (inView && !answerRes.isError) {
answerRes.fetchNextPage();
}
}, [answerRes, inView]);

const a = 1;

if (answerRes.isLoading) {
return <div>loading..</div>;
}

return (
<div>
<Container>
Expand All @@ -50,6 +55,7 @@ const AnswerVideos = () => {
views={v.views}
/>
))}
<div ref={ref} />
</VideoContainer>
</div>
);
Expand Down
7 changes: 2 additions & 5 deletions views/myPage/QuestionVideos.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from "@emotion/styled";
import { VideoItem } from "@views/myPage";
import { isError, useInfiniteQuery } from "react-query";
import { useInfiniteQuery } from "react-query";
import queryKey from "@constants/queryKey";
import { getMyQuesionList } from "@apis/myPage";
import { useInView } from "react-intersection-observer";
Expand All @@ -16,6 +16,7 @@ const QuestionVideos = () => {
},
{
getNextPageParam: (lastPage) => lastPage.page + 1,
retry: 0,
},
);

Expand All @@ -38,10 +39,6 @@ const QuestionVideos = () => {
return <div>loading..</div>;
}

// if (questionRes.isError) {
// return <div>Error.</div>;
// }

return (
<div>
<Container>
Expand Down

0 comments on commit 36a92d4

Please sign in to comment.