by lucasmullens · 7y ago · 0 comments
Isn't this missing the point? It's not about the overhead of declaring a new function, it's that you've made one of the props change on every render, so your child element needs to run its render function every time. The render function of Number only has to create a single H1 element which doesn't seem like a good test.
And the ExpensiveComponent example is strange to me. It's being memoized, so what exactly is the point?
This is the larger issue, but the `useCallback` hook can be used to memoize anonymous render functions based on given values to avoid this problem.