Let's say there is a function inside a component, for example like this:
const MyComponent = ({data}) => {
const myFunction = a => a+1;
return <div>
data.map(num => myFunction(num))
</div>
}
I don't want myFunction() to be called again if it already has been called with the same argument. What is the best practice to add caching here?