oblador / react-native-collapsible

Animated collapsible component for React Native, good for accordions, toggles etc
MIT License
2.43k stars 453 forks source link

How can I collapse it programmatically ? #353

Closed nandantal closed 3 years ago

nandantal commented 4 years ago

I want to collapse it on click of a button. Is there any way to do it ?

One way is by changing the active sections. Is there any other way ?

henrykuzmick commented 4 years ago

You can just change the collapsed prop on button click.

const [isCollapsed, setCollapsed] = useState(false)
<SomeButton onPress={() => setCollapsed(true)}>
    <Text>Press me</Text>
</SomeButton>
<Collapsible collapsed={isCollapsed}>
    <SomeContent />
</Collapsible>
wmonecke commented 3 years ago

@nandantal Could you please close this issue? :)