Skip to main content

React Parent and Child Component

Parent Component Updates

When a Parent Component's state or prop is updated and thus re-rendered, the child component that's part of the parent will also be re-rendered, or obviously when the child's state / props also changes.

https://whereisthemouse.com/react-components-when-do-children-re-render 

However, sometimes this is not necessary because parent changing doesn't necessarily mean child should also re-render. This is why this optimization of lifting the content up would help:

https://overreacted.io/before-you-memo/#solution-2-lift-content-up

You extract the child component into the child prop and make the parent render that, now because the child has become a prop, if the child doesn't change, then that mean the child won't be re-rendered. Saving optimization there.

This is referred to as lifting the content up