From 874a10992f3fe7c8aaac9e01df032fffd6656b05 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Wed, 26 Aug 2026 06:49:15 -0700 Subject: [PATCH] Fix React hooks ordering in post feed item By specifier. --- src/components/post-feed/post-feed-item.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/post-feed/post-feed-item.js b/src/components/post-feed/post-feed-item.js index 16357d0..32be55d 100644 --- a/src/components/post-feed/post-feed-item.js +++ b/src/components/post-feed/post-feed-item.js @@ -31,12 +31,14 @@ function PostFeedItem ({ showLikeButton = true, embedded = false }) { - if (!post) return null - + // React hooks must be called unconditionally before any early return, so + // declare the like state first and guard the post access after. const [liked, setLiked] = useState(false) - const [likeCount, setLikeCount] = useState(post.likeCount || 0) + const [likeCount, setLikeCount] = useState(post?.likeCount || 0) const [showLikeModal, setShowLikeModal] = useState(false) + if (!post) return null + const displayName = getDisplayName(post.addr, profiles) const hasCustomName = Boolean(