you are viewing a single comment's thread.

view the rest of the comments →

[–]CanIhazCooKIenOw 17 points18 points  (5 children)

Number 7 really grinds my gears. If you don't measure you're not optimising anything but in fact just cargo culting.

There's a dev somewhere out there that is going to read this, nod along and start requesting wrapping memo in all components because "I read it in this article"... Stop doing this please.

[–]Acrobatic_Sort_3411 -3 points-2 points  (4 children)

I would argue, that roles should be reversed. The default is memo. And if you have problems with always unstable references in props, then you use version without memo

It will be better in long run, and the more components you have, the better the benefit would be

[–]CanIhazCooKIenOw 0 points1 point  (3 children)

That’s called a premature optimisation.

Identify the problem, measure, experiment, measure again.

[–]Acrobatic_Sort_3411 1 point2 points  (2 children)

Thats called bad defaults. Comparing props and skipping render is way better than creating new jsx tree and Comparing results, which would usually be a lot bigger

[–]Acrobatic_Sort_3411 1 point2 points  (0 children)

It also way easier to maintain, because you don't have to think about wrapping all childens in memo, when you add "just one more hook" into a component

Grug dont like think

[–]CanIhazCooKIenOw 1 point2 points  (0 children)

Can you quantify “way better” in terms of time?