News for hackers. Stuff that matters.
Re:We memo all the things (2020) by Zababa on Monday October 25, 2021 @10:22AM (#28988114)
There's no mention of what I think is the most important point: how is this enforced? If that's with a tool, I think it's great and a sane way to do things. If it's by asking everyone to remember doing it, I think it's a missed opportunity.

It's also interesting to see the age-old functional programming problem: you trade performance for ease of development. I think these days people assume that things like immutable data structures are optimised under the hood. That doesn't seem to be the case with React, as you have to explicitly use a performance trick everywhere.

Their argument that it would be premature optimisation to think about where memo is not needed makes sense, it's an interesting shift of optimisation of the runtime performance vs optimisation of the dev time.

> Using memo and its cousins everywhere is a sane default. It’s like a mask mandate during a coronavirus pandemic. Sure, we could have everybody tested every day and only ask people who are actively contagious to wear a mask. But it’s far cheaper, simpler, and ultimately more effective to ask everybody to wear a mask by default.

That's a good metaphor. It's easier for the people who decide, by shifting the burden on everyone else. I personally get headaches by wearing a mask all the time at work. I think I may get headaches too if I had to remember something like this all the time.

Re:We memo all the things (2020) by nfRfqX5n on Monday October 25, 2021 @10:24AM (#28988138)
I think it would be easy to create a rule to see if the default export is wrapped in memo, but you could also just have it as a coding standard
Re:We memo all the things (2020) by Zababa on Monday October 25, 2021 @10:29AM (#28988207)
What do you mean by coding standard? My point was that if it's enforced by tool, either as a reminder, or an automatic modification, it's fine, but if it's not, it's annoying.
Re:We memo all the things (2020) by BinaryBullet on Monday October 25, 2021 @10:28AM (#28988185)
I wonder if this is the plugin they are using:

https://github.com/steadicat/eslint-plugin-react-memo

Does anyone know of any other eslint plugins that help enforce this?

Re:We memo all the things (2020) by fabiendem on Monday October 25, 2021 @01:00PM (#28990207)
The author of the article wrote the ESLint plugin: https://github.com/steadicat So they probably use(d) it.
Re:We memo all the things (2020) by Zababa on Monday October 25, 2021 @01:40PM (#28990757)
That's great!
Re:We memo all the things (2020) by fabiendem on Tuesday October 26, 2021 @11:57AM (#29002000)