Skip to content

Commit

Permalink
Merge pull request #316 from codestates-seb/feature/seunghw/mainIssue…
Browse files Browse the repository at this point in the history
…-298

#298 🐛 Fix : 무한스크롤 롤백
  • Loading branch information
devyuriii authored Dec 6, 2022
2 parents e1f942a + 6136caf commit a900ce0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions client/src/components/pages/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ const Main = () => {
const [infoData, setInfoData] = useState({});
const [count, setCount] = useState(1);
const [hasNext, setHasNext] = useState(true);
const [cursorId, setCurosrId] = useState(2000000000);
const SIZE = 5;
const SIZE = 10;
const [isDrawer, setIsDrawer] = useState(false);
const observerRef = useRef();
const preventRef = useRef(true);
Expand All @@ -34,13 +33,15 @@ const Main = () => {
const menuHandler = () => {
setIsDrawer(!isDrawer);
};

const getUserData = async () => {
const response = await client.get(
`/exercises?address-id=${address}&category=${category}&gender-type=${gender}&cursorId=${cursorId}&size=${SIZE}`,
`/exercises?address-id=${address}&category=${category}&gender-type=${gender}&cursorId=2000000000&size=${
count * SIZE
}`,
);
setHasNext(response.data.hasNext);
setUserData([...userData, ...response.data.data]);
setCurosrId(response.data.nextCursorId);
setUserData(response.data.data);
preventRef.current = true;
visited.current = true;
};
Expand Down

0 comments on commit a900ce0

Please sign in to comment.