react-native-collapsible close collapsible from any press

246 views Asked by At

I am using react-native-collapsible for a project. Everything working well but I would like the user to be able to close the collapsible by clicking anywhere on the screen when it is opened. On a desktop it would be easy with a !event.target match but since I am new to React Native (expo) I am a bit out of solution. Thanks a lot, I pasted no code because I am currently using the Lorem example from the lib so won't be much useful.

1

There are 1 answers

0
Ankit Vora On

You can Make one useState variable and pass it into the property of collapsed={Your useState Veriable} react-native-collapsible . also make all the Design wrap into TouchableOpacity and it's onPress event to make it true.