Answer the question
In order to leave comments, you need to log in
When does a component rerender in react?
Hello! There are incomprehensible moments on understanding the redrawing of components.
In theory, re-rendering of components in react is called when:
1. Changing the component's internal state (this.setState);
2. Changing the properties (props) of the component received from the parent or redrawing the parent.
It's not clear here. If the internal state on the topmost App component changes, will absolutely all the components down the tree be redrawn? And if only 1 out of 10 received a change in the transmitted props, and for the rest, the incoming props data did not change, will they all be redrawn anyway?
3. When changing the context. A comment is also needed on this point. It is not clear how the passed object with data can change with the help of context during the operation of the application? Can the list of properties change on the fly?
Answer the question
In order to leave comments, you need to log in
1. Component redraw occurs as a result of parent redraw or calls to this.setState() or this.forceUpdate().
It can be controlled in class components with the shouldComponentUpdate lifecycle method. When this.forceUpdate() is called, shouldComponentUpdate is not called.
2.
Changing the properties (props) of the component received from the parent or redrawing the parent.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question