Hacker News new | ask | show | jobs
by o_____________o 3312 days ago
> If we recommended that PureComponent be used everywhere, it would probably be the default already.

> Instead, we'd suggest you be conscious of where you need to do the comparisons.

I'm not following, wouldn't that mean PureComponent by default and opt-in specialized checks when needed?

1 comments

No, because PureComponent does have a check.

His point is that you don't always need that check - that check has overhead too!

Basically PureComponent is just a specialized case of shouldComponentUpdate so it's better practice to be mindful of where you're calling that anyhow.

It's also why there's the push to use stateless functions (when you can) because the kind of pseudo micro-optimization that PureComponent actually is can have counter-intuitive consequences.