I've found in docs that Flatlist
, SectionList
are PureComponents
. There isn't any information about other components (e.g TouchableOpacity
).
I want to find out which RN build-in component is pure to use useCallback
when it's necessary.
If all other components aren't pure it isn't necessary to use useCallback
in this example.
export default App = () => {
const [count, setCount] = useState(0);
const onPress = useCallback(() => setCount(prevCount => prevCount + 1), [prevCount]);
return (
<View style={styles.container}>
<TouchableOpacity
style={styles.button}
onPress={onPress}
>
<Text>Press Here</Text>
</TouchableOpacity>
</View>
);
};