ComponentWillReceiveProps executed twice. Why?

background:
purpose brief: click the button, adjust this.props.history.push () to cause the change of location, and judge in componentWillReceiveProps that if prev.location and next.location, are not equal, the mask layer is displayed.
question
first declare that the current component does not have child components. Printing a random console.log (XXX), in componentWillReceiveProps is executed (printed) twice. Why?

Mar.20,2021

see if there is any place to modify the props of the component


clipboard.png
cwr
clipboard.png
render

render
clipboard.png
then it's not hard to find that there are two ways. One is initialized, and the other is render, the parent component of the parent component.

then why the parent component of the parent component render twice, then look at the parent component of the parent component.

if you have any questions about this answer, please take it. Thank you

Menu