dont render 0
This commit is contained in:
@@ -52,6 +52,8 @@ export function CountWheel({
|
|||||||
|
|
||||||
const [prevCount, setPrevCount] = React.useState(likeCount)
|
const [prevCount, setPrevCount] = React.useState(likeCount)
|
||||||
const prevIsLiked = React.useRef(isLiked)
|
const prevIsLiked = React.useRef(isLiked)
|
||||||
|
const formattedCount = formatCount(likeCount)
|
||||||
|
const formattedPrevCount = formatCount(prevCount)
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isLiked === prevIsLiked.current) {
|
if (isLiked === prevIsLiked.current) {
|
||||||
@@ -73,12 +75,12 @@ export function CountWheel({
|
|||||||
prevIsLiked.current = isLiked
|
prevIsLiked.current = isLiked
|
||||||
}, [isLiked, likeCount, shouldAnimate, shouldRoll])
|
}, [isLiked, likeCount, shouldAnimate, shouldRoll])
|
||||||
|
|
||||||
const formattedCount = formatCount(likeCount)
|
if (likeCount < 1) {
|
||||||
const formattedPrevCount = formatCount(prevCount)
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
{likeCount > 0 ? (
|
|
||||||
<View
|
<View
|
||||||
aria-disabled={true}
|
aria-disabled={true}
|
||||||
// @ts-expect-error is div
|
// @ts-expect-error is div
|
||||||
@@ -95,7 +97,6 @@ export function CountWheel({
|
|||||||
{formattedCount}
|
{formattedCount}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
|
||||||
<View
|
<View
|
||||||
style={{position: 'absolute'}}
|
style={{position: 'absolute'}}
|
||||||
aria-disabled={true}
|
aria-disabled={true}
|
||||||
|
|||||||
Reference in New Issue
Block a user