Skip to content

Commit

Permalink
refactor: createVNode falsy 필터 수정, HomePage 구독 함수 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
BoYoung00 committed Dec 27, 2024
1 parent 3476f61 commit b95c91f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
6 changes: 1 addition & 5 deletions src/lib/createVNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ export function createVNode(type, props, ...children) {
return {
type,
props: props || null,
children: children
.flat(Infinity)
.filter(
(child) => child !== false && child !== null && child !== undefined,
),
children: children.flat(Infinity).filter((child) => child || child === 0),
};
}
18 changes: 5 additions & 13 deletions src/pages/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ export const HomePage = () => {
let { posts } = globalStore.getState();
const { loggedIn } = globalStore.getState();

const pageUpdate = () => {
const { posts: updatedPosts } = globalStore.getState();
posts = updatedPosts;
render();
const isLikedByCurrentUser = (post) => {
const { currentUser } = globalStore.getState();
return post.likeUsers.some((user) => user === currentUser.username);
};

globalStore.subscribe(pageUpdate);

const render = () => (
return (
<div className="bg-gray-100 min-h-screen flex justify-center">
<div className="max-w-md w-full">
<Header />
Expand All @@ -45,11 +42,6 @@ export const HomePage = () => {
</div>
</div>
);

return render();
};

const isLikedByCurrentUser = (post) => {
const { currentUser } = globalStore.getState();
return post.likeUsers.some((user) => user === currentUser.username);
};
globalStore.subscribe(HomePage);

0 comments on commit b95c91f

Please sign in to comment.