Hacker News new | ask | show | jobs
by mehagar 350 days ago
More likely they don't even need to use useMemo if it's not an expensive calculation. They can just calculate the dependent values during rendering, which is explained in the docs: https://react.dev/learn/you-might-not-need-an-effect#updatin...

If `getLinkedCats` calls an external API, then the calculation can instead be all in the same useEffect.

The number one mistake I see people inexperienced with React doing is using too many useEffect's in their code, which is both hard to read and hurts performance, since it results in more renders than necessary.

1 comments

I'll point out that just on this comment string from telmac are 3 different interpretations of what is wrong with the code and what should be done instead.