diff --git a/src/lib/custom-animations/CountWheel.tsx b/src/lib/custom-animations/CountWheel.tsx index ccc30c2146..130c71096e 100644 --- a/src/lib/custom-animations/CountWheel.tsx +++ b/src/lib/custom-animations/CountWheel.tsx @@ -106,6 +106,8 @@ export function CountWheel({ const [key, setKey] = React.useState(0) const [prevCount, setPrevCount] = React.useState(likeCount) const prevIsLiked = React.useRef(isLiked) + const formattedCount = formatCount(likeCount) + const formattedPrevCount = formatCount(prevCount) React.useEffect(() => { if (isLiked === prevIsLiked.current) { @@ -118,9 +120,6 @@ export function CountWheel({ prevIsLiked.current = isLiked }, [isLiked, likeCount]) - const formattedCount = formatCount(likeCount) - const formattedPrevCount = formatCount(prevCount) - const enteringAnimation = shouldAnimate && shouldRoll ? isLiked @@ -136,8 +135,8 @@ export function CountWheel({ return ( - - {likeCount > 0 ? ( + {likeCount > 0 ? ( + - ) : null} - {/* Add 2 to the key so there are never duplicates */} - - - {formattedPrevCount} - - - + + + {formattedPrevCount} + + + + ) : null} ) }