3/7 (shouldComponentUpdate) unclear

I have a question about 3/7 chapter (shouldComponentUpdate) in that fine course.
Let us go to Instructions. 2

In that point one defines that line of code

shouldComponentUpdate (nextProps, nextState){return this.props.number != nextProps.number;};

Explanation why it works is that it “return false when a target has already rendered, and is about to repeat the same number as its last render. This will cause Target to cancel its update.”

I must admit - I do not see WHY that line is expected to have THAT effect. Could I ask for simple explanation? Sorry, but I am quite new to IT.


A comparison (this.props.number != nextProps.number;) will return a Boolean value (true or false)

when shouldComponentUpdate returns False, reactJS stops re-rendering the component. Whoever designed that function/method build it in such a way that we can stop a component from re-rendering if we want.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.