News for hackers. Stuff that matters.
Re:React Docs Beta – rewritten with hooks and interactive ex... by cageface on Sunday October 24, 2021 @02:38AM (#28975450)
The problem with using useMemo & useCallback everywhere is that the dependency arrays are really easy to get wrong. Small changes can easily lead to stale data or render loops. I'd much rather people take the time to consider each case. The React profiler is your friend here.
Re:React Docs Beta – rewritten with hooks and interactive ex... by kylorhall on Sunday October 24, 2021 @04:31AM (#28975924)
I think if you use them 100% of the time alongside eslint dependency arrays are really hard to get wrong. If you rarely use them, you always get them wrong.
Re:React Docs Beta – rewritten with hooks and interactive ex... by cageface on Sunday October 24, 2021 @04:37AM (#28975968)
If you just blindly follow the eslint suggestions you can very easily wind up with render loops. You need to carefully consider and understand the dependencies in each case. And if you want to do something specific when only one of your dependencies changes you need even more gymnastics.
Re:React Docs Beta – rewritten with hooks and interactive ex... by atom_arranger on Sunday October 24, 2021 @07:54AM (#28977084)
The reason you end up with render loops is usually because you didn’t memo something. If you memo everything you can avoid that issue.