lundi 9 novembre 2020

React's design philosophy: Why update child-components when props haven't changed?

As we know, when a node changes, every child component is automatically re-rendered; even if their props remain the same.

It's possible to design around this by using shouldComponentUpdate, PureComponent or React.memo.

However, I'm curious, why is it necessary to re-render by default? I can't think of an instance where if a child component's props are identical, that it'll need to be re-rendered. Though perhaps I'm missing something...

Aucun commentaire:

Enregistrer un commentaire