I am working on a React Native project and I have a TouchableOpacity component in my view with an onPress method. I want to avoid using arrow functions and bind functions in the onPress method as it creates a new function every time. My goal is to pass parameters to the onPress method. Below is the code snippet:
<TouchableOpacity
activeOpacity={0.9}
style={styles.touchOfferItem}
onPress={() => this.gotoOfferDetail(item)}
accessibilityLabel={`Test`}
testID={'Test'}
accessible={false}>
</TouchableOpacity>
gotoOfferDetail (offerData:IOfferDetailItem) {
console.log(offerData.title)
}
I want to find a solution that does not involve using arrow functions in the onPress attribute, as it results in JSX props should not use arrow functions. Can anyone provide guidance on this issue and suggest possible solutions?
Any assistance would be greatly appreciated.
I have tried searching for solutions but have been unsuccessful so far.