Skip to content

Commit

Permalink
Merge pull request #694 from woowacourse/hotfix/view-count
Browse files Browse the repository at this point in the history
fix: 조회수가 2씩 증가하는 오류 수정
  • Loading branch information
gracefulBrown authored Feb 6, 2022
2 parents e8032a7 + 939318a commit d410c44
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions frontend/src/pages/StudylogPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import { ButtonList, EditButtonStyle, DeleteButtonStyle } from './styles';
import { MainContentStyle } from '../../PageRouter';
import { UserContext } from '../../contexts/UserProvider';
import useSnackBar from '../../hooks/useSnackBar';
import useRequest from '../../hooks/useRequest';
import useStudylog from '../../hooks/useStudylog';
import useMutation from '../../hooks/useMutation';
import debounce from '../../utils/debounce';

import {
requestPostScrap,
requestDeleteScrap,
requestDeleteLike,
requestGetStudylog,
requestDeleteStudylog,
requestPostLike,
} from '../../service/requests';
Expand All @@ -40,9 +39,8 @@ const StudylogPage = () => {

const { openSnackBar } = useSnackBar();

const { response: studylog, fetchData: getStudylog } = useRequest({}, () =>
requestGetStudylog({ id, accessToken })
);
const { response: studylog, getData } = useStudylog({});
const getStudylog = () => getData({ id, accessToken });

const { mutate: deleteStudylog } = useMutation(
() => {
Expand Down Expand Up @@ -157,7 +155,12 @@ const StudylogPage = () => {
};

useEffect(() => {
getStudylog();
// accessToken 이 있을 시에 studylogs -> me -> studylogs 순서 제어를 위한 임시 코드
const timeout = setTimeout(() => getStudylog(), 0);

return () => {
clearTimeout(timeout);
};
}, [accessToken, id]);

return (
Expand Down

0 comments on commit d410c44

Please sign in to comment.