Fix React hooks ordering in post feed item

By specifier.
This commit is contained in:
Chris Troutner
2026-08-26 06:49:15 -07:00
parent 61d50dfa88
commit 874a10992f
+5 -3
View File
@@ -31,12 +31,14 @@ function PostFeedItem ({
showLikeButton = true, showLikeButton = true,
embedded = false 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 [liked, setLiked] = useState(false)
const [likeCount, setLikeCount] = useState(post.likeCount || 0) const [likeCount, setLikeCount] = useState(post?.likeCount || 0)
const [showLikeModal, setShowLikeModal] = useState(false) const [showLikeModal, setShowLikeModal] = useState(false)
if (!post) return null
const displayName = getDisplayName(post.addr, profiles) const displayName = getDisplayName(post.addr, profiles)
const hasCustomName = Boolean( const hasCustomName = Boolean(