top | item 32506597

(no title)

soft_dev_person | 3 years ago

> Following this articles advice will likely make your app render slower than not optimizing at all.

Yes, but it will not actually matter in >99% of real world cases. And this argument is exactly what the article mentions, premature optimization.

> Caching everything increases your risk of stale data through misconfiguration.

Yes, but doing the opposite increases the risk of useEffects triggering unnecessarily (and wildly).

> The issue people have with hooks is primarily caused by 99% of folks not quite understanding just how sparingly hooks should be used.

I strongly disagree. The consequences of not using it by default, then arriving at a case where it matters, are so much bigger than the minor performance impact using it "everywhere" has.

But you need to have experienced this in a large and complex application to really feel it, I suppose.

discuss

order

amccloud|3 years ago

> Yes, but it will not actually matter in >99% of real world cases. And this argument is exactly what the article mentions, premature optimization.

The author talks about non of the downsides of their approach. They are real.

> Yes, but doing the opposite increases the risk of useEffects triggering unnecessarily (and wildly).

useEffect in your component should be rare. Effects should not come from watching state/props. Effects should come from interactions.

> I strongly disagree. The consequences of not using it by default, then arriving at a case where it matters, are so much bigger than the minor performance impact using it "everywhere" has.

Explains why your viewpoint currently aligns with the author. I can tell from what you've said so far you use useEffect too much, which causes you to rely on referential equality more.

> But you need to have experienced this in a large and complex application to really feel it, I suppose.

Assume I have?

soft_dev_person|3 years ago

> The author talks about non of the downsides of their approach

The whole article is a counterpoint to a common falsehood. The downsides have been overstated a lot already.

> useEffect in your component should be rare.

Route is state too. Loading data based on route is very common. There is no reason to avoid useEffect for triggering side effects based on state or props in components. It's the whole reason it exists...

Or do you only use libraries for loading data, without realizing they rely on useEffect, perhaps?

> I can tell from what you've said so far you use useEffect too much

And I can tell from what you've said that you have fairly limited experience with React, or have not developed a variety of web applications with it.

> Assume I have?

Your statements make that difficult.