Skip to content

Commit

Permalink
fix: 북마크 후 리렌더링 되는 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Songhyejeong committed Nov 17, 2024
1 parent 8f3171e commit 4c7bc0e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/components/common/bookmark/BookmarkContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ const BookmarkContainer = ({ bookmarkId, storeId }) => {
if (response.status === 204) {
console.log('success delete');
fetchBookmarkStores();
navigate(0);
}
} else {
const response = await postBookmarkStore(storeId);
if (response.status === 201) {
fetchBookmarkStores();
navigate(0);
} else {
console.log(response.error);
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/store/StoreCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const StoreListCard = ({ image, alt, id, name, address, rating, positiveRatio, p

return (
<StoreListCardLayout>
<ContentsContainer onClick={() => cardClickHandler(id)}>
<ImageContainer>
<ContentsContainer>
<ImageContainer onClick={() => cardClickHandler(id)}>
<StyledImage src={image} alt={alt} />
</ImageContainer>
<ContentsBox>
<NameAndBookmarkContainer>
<p>{name}</p>
<p onClick={() => cardClickHandler(id)}>{name}</p>
<Bookmark bookmarkId={bookmarkId} storeId={id} />
</NameAndBookmarkContainer>
<RatingContainer>
Expand Down
2 changes: 1 addition & 1 deletion src/components/storeCard/TopStoreCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const TopStoreCard = ({ image, alt, bookmarkId, id, address, name, positiveRatio

useEffect(() => {
if (!bookmarkId) {
const bookmark = savedStores.filter((store) => store.storeResponseDto.storeId === id);
const bookmark = savedStores.find((store) => store.storeResponseDto.storeId === id);
const bookmarkId = bookmark?.bookmarkId;
setSavedId(bookmarkId);
}
Expand Down

0 comments on commit 4c7bc0e

Please sign in to comment.