📚 Whenever I see useCallback, I wonder: why do we need it here? And a lot of the times, when I look deeper, I see that it actually doesn’t do anything. I think a lot of code-bases would be better of just not memoizing at all - and then let the compiler do it for you:
Post
I think if you’re building a simple app it’s overkill. If like us you’re building a calendar and need buttery smooth mouse interaction performance, a single missing useCallback can cause the whole app to rerender on every mouse move and make it feel atrocious. Just depends on the context really.
How do you make sure that a single wrong prop doesn't introduce a laggy interaction? Is there a way to test for that? Are you using the react compiler, because it seems like a great fit here
0 reposts0 likes
I’ve never looked into it properly - some of our work pre dates the compiler. Does it work in dev mode with hot reloading etc? It’s probably not the best code but our dependency arrays are not always equal to everything used in the function so I assumed the compiler wouldn’t be able to handle that