The difference between push and replace in react: push jump will form a history and can return to the previous layer; replace jump will not form a history and cannot return to the previous layer. It is applicable after login. Need to go back to the login page.
The operating environment of this tutorial: windows7 system, react16 version, Dell G3 computer.
The difference between push and replace in react
push:a-b-c, you can return to the previous level
push jump A history will be formed and you can return to the previous layer.
Syntax:
this.props.history.push('router地址')
replace:a-b-c cannot return to the previous level. It is applicable after logging in and there is no need to return to the login page
replace jump will not form a history and cannot return to the previous level.
Grammar:
this.props.history.replace('router地址')
For more programming-related knowledge, please visit:Programming Teaching! !
Related tutorial recommendations:React video tutorial
The above is the detailed content of What is the difference between push and replace in react. For more information, please follow other related articles on the PHP Chinese website!