Home > Software engineering >  Avoid instant trigger of multiple click on Touchableopacity in react-native
Avoid instant trigger of multiple click on Touchableopacity in react-native

Time:11-23

When I click submit button (TouchableOpacity is used) multiple times instantly it will trigger the function multiple times. Any suggetion to fix this issue.

CodePudding user response:

You can create a loading state and pass that state to the disabled prop of touchableOpactiy.That way the button will be disable while the operation completes

CodePudding user response:

you can use a state and settimeout function for that,

after clicking the TouchableOpacity just set the state false and in set timeout change it to true after some time

  • Related