DEV Community

Discussion on: Components are Pure Overhead

Collapse
 
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

But more importantly, there is a solution to isolate updates that every React developer knows. No, it's not useMemo. Create a child component.

This part confused me, but I may have misunderstood what you were going for. Please correct me if I'm mistaken, but when a parent component re-renders, so will all of its children, unless those children:

  1. Are pure components (available in class components).
  2. Have a shouldComponentUpdate that always returns false (basically same as #1 but more explicit).
  3. Are wrapped with the React.memo HOC.
Collapse
 
ryansolid profile image
Ryan Carniato

I'm over-generalizing. So apologize for the inaccuracy. That differs between VDOM implementations. Some do check the props directly. But you are correct that is what it means for React specifically.

Collapse
 
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

Ah, all good! I thought I'd misunderstood something.