CLOSE
_onPress(e) {
The concern is about performance so I solve it with this approach
just create a wrapper around TouchableOpacity or any clickable view
import { TouchableOpacity } from "react-native"
export const TouchableOpacityOnPressOptimized = ({ children, onPress, index }) => {
return (
onPress(index)}>
{children}
)
}
const touchMe = (index) => {
switch(index) {
case 1: alert('index is' + index)
case 2: alert('index is' + index)
}
}
touch me 1
touch me 2
touch me 3
this way your touchable component not re-render