mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo-client.git
synced 2026-09-21 16:52:02 -07:00
Fix React hooks ordering in post feed item
By specifier.
This commit is contained in:
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user