Skip to content

Commit

Permalink
sdp-tech#559 fix : go back get item
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsikkk committed Nov 9, 2023
1 parent 0169f4a commit 75d12d3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/SpotMap/DataContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function DataContainer({ Location }) {
const queryParams = {
left: location.state?.lat || searchHere.lat,
right: location.state?.lng || searchHere.lng,
page: page,
page: queryString.page,
search: location.state?.name || localStorage.getItem("place_name") || search.trim(),
filter: checkedList
}
Expand Down Expand Up @@ -149,7 +149,7 @@ export default function DataContainer({ Location }) {
setCategoryNum(7);
}
getList();
}, [searchHere, search, checkedList, page]);
}, [searchHere, search, checkedList, queryString.page]);

return (
<>
Expand Down
7 changes: 5 additions & 2 deletions src/components/mypick/mycuration/MyCuration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ const MyCuration = (props) => {
const [page, setPage] = useState(1);
const [pageOneFlag, setPageOneFlag] = useState(false);
const nickname = localStorage.getItem('nickname');
const queryString = qs.parse(location.search, {
ignoreQueryPrefix: true
});

const onCheckedElement = (checked, item) => {
checked ? setCheckedList([...checkedList, item]) : setCheckedList(checkedList.filter((el) => el !== item));
Expand All @@ -171,7 +174,7 @@ const MyCuration = (props) => {
setLoading(true);

const response = await request.get("/mypage/my_liked_curation/", {
page: page,
page: queryString.page,
search: search.trim()
}, null);

Expand Down Expand Up @@ -201,7 +204,7 @@ const MyCuration = (props) => {
// 초기에 좋아요 목록 불러오기
useEffect(() => {
pageMyCuration();
}, [page]);
}, [queryString.page]);
return (
<>
{loading ? (
Expand Down
7 changes: 5 additions & 2 deletions src/components/mypick/myplace/Myplace.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ const Myplace = () => {
const navigate = useNavigate();
const request = Request(navigate);
const nickname = localStorage.getItem('nickname');
const queryString = qs.parse(location.search, {
ignoreQueryPrefix: true
});

// onChange함수를 사용하여 이벤트 감지, 필요한 값 받아오기
const onCheckedElement = (checked, item) => {
Expand All @@ -171,7 +174,7 @@ const Myplace = () => {
let params = new URLSearchParams();
for (const category of checkedList) params.append('filter', category);
const response = await request.get(`/mypage/myplace_search/?${params.toString()}`, {
page: page,
page: queryString.page,
search: search.trim()
}, null);
setPageCount(response.data.data.count);
Expand Down Expand Up @@ -202,7 +205,7 @@ const Myplace = () => {
// 초기에 좋아요 목록 불러오기
useEffect(() => {
pageMyplace();
}, [page, checkedList]);
}, [queryString.page, checkedList]);

return (
<>
Expand Down
13 changes: 9 additions & 4 deletions src/components/mypick/mystory/Mystory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ const Mystory = () => {
const [page, setPage] = useState(1);
const [pageOneFlag, setPageOneFlag] = useState(false);
const nickname = localStorage.getItem('nickname');
const queryString = qs.parse(location.search, {
ignoreQueryPrefix: true
});

// onChange함수를 사용하여 이벤트 감지, 필요한 값 받아오기
const onCheckedElement = (checked, item) => {
Expand All @@ -174,7 +177,7 @@ const Mystory = () => {
for (const category of checkedList) params.append('filter', category);

const response = await request.get(`/mypage/mypick_story/?${params.toString()}`, {
page: page,
page: queryString.page,
search: search.trim()
}, null);

Expand All @@ -185,8 +188,10 @@ const Mystory = () => {

useEffect(() => {
if (search || checkedList) setPage(1);
}, [checkedList, search]);

if (parseInt(queryString.page) !== page) setPage(parseInt(queryString.page));
}, [checkedList, search, queryString.page]);
console.log(queryString.page);
console.log(page);
useEffect(() => {
const params = {
page: page,
Expand All @@ -205,7 +210,7 @@ const Mystory = () => {
// 초기에 좋아요 목록 불러오기
useEffect(() => {
pageMystory();
}, [page, checkedList]);
}, [queryString.page, checkedList]);
return (
<>
{loading ? (
Expand Down

0 comments on commit 75d12d3

Please sign in to comment.