What is the difference between push and replace in react

青灯夜游
Release: 2023-01-04 09:37:52
Original
6491 people have browsed it

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.

What is the difference between push and replace in react

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地址')
Copy after login

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地址')
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!