Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLaurence Marrin
2,522 PointsWhy wouldn't you just always use PureComponent instead of Component?
Likewise, why wouldn't React just have the normal Component class work like PureComponent?
1 Answer
toxic
UX Design Techdegree Student 14,790 PointsHi Laurence.
Component and PureComponent have one difference
PureComponent is exactly the same as Component except that it handles the shouldComponentUpdate method for you. When props or state changes, PureComponent will do a shallow comparison on both props and state. Component on the other hand wonβt compare current props and state to next out of the box. Thus, the component will re-render by default whenever shouldComponentUpdate is called.