how can I disable a touchable opacity for a minute after it is pressed.
let disable = false
<TouchableOpacity
style={styles.btnSolid}
onPress={() => {
resetUserPswd(auth, Email, navigation);
disable = false;
}}
disabled = {disable}
>
<Text style={styles.btnTextSolid}>Send Email</Text>
</TouchableOpacity>
thanks in advance.
You can use setTimeout like this:
import { useEffect, useState } from 'react';
const [disabled, setDisabled] = useState(false);
const [pressed, setPressed] = useState(false);
useEffect(() => {
if (disabled || !pressed) {
return;
}
const timer = setTimeout(() => {
setDisabled(true);
}, 60000);
return () => clearTimeout(timer);
}, [pressed]);
<TouchableOpacity
style={styles.btnSolid}
onPress={() => {
resetUserPswd(auth, Email, navigation);
setPressed(true);
}}
disabled = {disabled}
>
<Text style={styles.btnTextSolid}>Send Email</Text>
</TouchableOpacity>