Skip to content

Commit

Permalink
fix: react query 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ArpaAP committed Nov 5, 2024
1 parent 340a197 commit 5957892
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/pages/Board.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,7 @@ export default function Board() {

const { data, isLoading } = useQuery(
['posts-tag-search', tag, debouncedSearch],
() => {
if (tag === '전체') {
return API.GET(`/posts?search=${debouncedSearch}`);
}
return API.GET(`/posts?tag=${tag}&search=${debouncedSearch}`);
},
() => API.GET(`/posts?search=${debouncedSearch}`),
);

return (
Expand Down Expand Up @@ -212,16 +207,18 @@ export default function Board() {
{isLoading ? (
<Text>불러오는 중</Text>
) : (
data?.data?.content?.map((post, index) => (
<PostCard
key={index}
id={post.id}
title={post.title}
description={post.description}
user={post.user}
image={extractBase64ImageData(post.content)[0]}
/>
))
data?.data?.content
?.filter((post) => tag === '전체' || tag == post.tag)
.map((post, index) => (
<PostCard
key={index}
id={post.id}
title={post.title}
description={post.description}
user={post.user}
image={extractBase64ImageData(post.content)[0]}
/>
))
)}
</PostItems>
</Container>
Expand Down

0 comments on commit 5957892

Please sign in to comment.