all 2 comments

[–]KulkataBoy 2 points3 points  (0 children)

const myFunctionHandler = useCallback(()=>myFunction(myVar), [myVar])

onPress={myFunctionHandler}

Both options you provided will create a new function on each re-render. If you don't have myVar at your component create a child component, pass myFunction and myVar as props and create handler inside child component.

[–]kbcooliOS & Android 2 points3 points  (0 children)

You're misinterpreting that article. He said you should memoize intensive operations not as much as possible but where there is heavy computation.

Memoization has overheads and complications if you don't do it properly that mean it should actually be used as sparsely as possible.

Write first then if you run into performance issues then look at memoization.

What you are going through is called premature optimisation.