I've created a button that I want to have call a function on click and then again on release. A normal TouchableOpacity or other will trigger a function upon release of a click only, I need functions on both click AND release.
<View
style={styles.touchbutton}
onStartShouldSetResponder={() => this.clickOn()}
onResponderRelease={() => this.clickRelease()}>
<Text style={styles.dark}>Button</Text>
</View>
The above code works on click but not on release. I also tried onResponderReject but that doesn't work either. Hard to find what the command should be.
We will introduce how to disable the button in react. js using a disabled prop to our button element. To simply disable the button, we can use the disabled prop in our button element and set its value to true . If we want to disable our button after clicking on it, We can disable it by using react's state.
You can use onViewableItemsChanged to check which viewableItems are on the screen.
js */ import React from "react"; import { Button, StyleSheet, Text, View } from "react-native"; function App() { const getDeviceType = (e) => { console. log(e); }; return ( <View style={styles. app} pointerEvents="box-none"> <View style={styles. header}> <Text style={styles.
Unfortunately, React Native's basic components currently can't render to basic HTML elements. Your React Native code can be reused across iOS and Android (and any future React Native platforms), but it can't render to web-compatible views.
Had the same problem. onStartShouldSetResponder
needs to return true
.
onStartShouldSetResponder={(e) => {
/*do whatever*/;
return true
}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With