News for hackers. Stuff that matters.
Re:When does React re-render? Explaining rerenders and how t... by matthewmacleod on Wednesday April 29, 2020 @05:41AM (#23017252)
Premature optimisation is a problem, but I'd say in general it's a better approach to just start out by doing the fast thing. Memoising (or using PureComponent or whatever) is an absolutely minimal cost if you're using an appropriate architecture – my experience suggests that it's way easier to do that from the outset with everything—adding some exceptions where required—rather than trying to detangle a large SPA that uses mutable props everywhere later on.

It's probably good advice to avoid lots of custom shouldComponentUpdate logic though. That's smelly.

Re:When does React re-render? Explaining rerenders and how t... by davedx on Wednesday April 29, 2020 @05:51AM (#23017323)
> Premature optimisation is a problem, but I'd say in general it's a better approach to just start out by doing the fast thing

This is contradictory

Re:When does React re-render? Explaining rerenders and how t... by ragnese on Wednesday April 29, 2020 @07:20AM (#23017870)
The keyword is "premature".

The whole silly meme of "premature optimization is the root of all evil" is a 100% useless statement. Of course, you shouldn't do it yet if it's premature- that's the definition of premature.

But if it's almost the same amount of effort to write faster code from the get go- especially if you KNOW the code will be speed-sensitive, then you should absolutely try to do the fast thing over the slow thing. That seems obvious...