DEV Community

Discussion on: 🔥 🔥 🔥 Do you know all these means to avoid repeated rendering of React components?

Collapse
 
souksyp profile image
Souk Syp.

I used PureComponent for every class component. Is it a bad practice ? 😟

Collapse
 
badpractice profile image
Bad Practice

I'll be the judge of that

Collapse
 
johnsawiris profile image
John Sawiris

Yes, that is a bad practice what you're doing is premature optimization, and that is the root of all evil.
PureComponent optimize the performance when you have a performe issue; using it without an issue will hinder the performance because every component has to call shouldComponentUpdate and that doesn't happen for free. And functional components are not the answer either, they're not that much different from class components.

Collapse
 
liujinyi profile image
liu-jin-yi • Edited

Agree

Collapse
 
souksyp profile image
Souk Syp.

Okay, thanks! Man need a fix

Collapse
 
blackr1234 profile image
blackr1234

I use memo for all function components but I always provide the comparison condition.