gluestack-ui icon indicating copy to clipboard operation
gluestack-ui copied to clipboard

I cannot update Badge action by state

Open phalera opened this issue 1 year ago • 1 comments

Description

I cannot update Badge action by state

CodeSandbox/Snack link

below

Steps to reproduce

const [isMuted, setIsMuted] = useState(false);

useEffect(() => {
  setTimeout(() => setMuted(prev => !prev), 1000);
}, [])

return (
  <Badge action={isMuted ? 'muted' : 'info'}>
    <BadgeText>test badge</Badge>
  </Badge>
)

gluestack-ui Version

1.1.39

Platform

  • [ ] Expo
  • [ ] React Native CLI
  • [ ] Next
  • [ ] Web
  • [X] Android
  • [X] iOS

Other Platform

No response

Additional Information

No response

phalera avatar Jul 15 '24 13:07 phalera

Had the same issue trying to use state for updates. A workaround is to set a key prop that changes with state - forces a new component render.

jkearney126 avatar Aug 01 '24 15:08 jkearney126