[React 19] is the new compiler remove this unnecessary usgae of the useCallback
TonyFTannous-Byd opened this issue · 2 comments
Hello,
using React 19 with the implementation of the new compiler (babel-plugin-react-compiler), no need to use useCallback and memo... explicitly because the new compiler do this job (as react compiler documentation).
my question is if explicitly i use useCallback with a function in my functional component not need the usage of useCallback (significant performance gains). is the new compiler remove this unnecessary usgae of the useCallback?
thanks...
I can't completely answer your question, but I doubt that the compiler would remove explicit useCallback
calls. I found a section on explicitly disabling auto-memoization by providing a "use no memo"
directive. Hope this helps.
The compiler removes useMemo and use callback calls and replaces them with its own, more fine-grained memoization. You can use https://playground.react.dev to see what the output would be for a given file.