I want to ask you, should I use "useCallback" when I navigate to any screen or is that unnecessary?
...
const navigateToScreen = useCallback(() => {
navigation.navigate('screen')
}, []);
And if I should use "useCallback" then what I have to do in the array ?
CodePudding user response:
No, you should simply navigate to the other page onClick etc... without UseCallback.
UseCallback is useful when you recreate a function/object on every render, which can be very expensive (if it is a complex calculation, or very large object), and slow your app down a lot. You can pass a variable into the empty array, telling UseCallback to run every time this variable changes.
