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,29 +75,28 @@ 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
|
ref={countView}>
|
||||||
ref={countView}>
|
<Text
|
||||||
<Text
|
testID="likeCount"
|
||||||
testID="likeCount"
|
style={[
|
||||||
style={[
|
big ? a.text_md : {fontSize: 15},
|
||||||
big ? a.text_md : {fontSize: 15},
|
a.user_select_none,
|
||||||
a.user_select_none,
|
isLiked
|
||||||
isLiked
|
? [a.font_bold, s.likeColor]
|
||||||
? [a.font_bold, s.likeColor]
|
: {color: t.palette.contrast_500},
|
||||||
: {color: t.palette.contrast_500},
|
]}>
|
||||||
]}>
|
{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