Home > Web Front-end > Front-end Q&A > How to achieve page jump without recording in react

How to achieve page jump without recording in react

藏色散人
Release: 2022-12-30 10:07:28
Original
2613 people have browsed it

React method to realize page jump without recording: 1. Open the corresponding react file; 2. Use the "this.props.history.replace("/home");" method to realize page jump and clear it Just the history of the current page.

How to achieve page jump without recording in react

The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.

How to achieve page jump without recording in react?

React-router: Page jump and clear the history of the current page

There are the following situations:

The user opens the activation link; after the user completes the activation process, It will be moved to another page.

I don't want to keep the activation link in the browser's history because when the user returns, they will enter the activation step again.

You can jump to the page through replace

this.props.history.replace("/home");
Copy after login

Related introduction:

this.props.history.replace()The parameter in this method is the Link whose replace attribute is true The to attribute of the component can also pass state;

 this.props.history.replace(`/Page2/Div1`)
 //等同于
 <Link replace to=`/Page2/Div1`></Link>
 this.props.history.replace(`/Page2/Div1`,{ id: 1, message: "你好啊" })
 //等同于
 <Link replace to={{pathname:`/Page2/Div1`,state:{id: 1, message: "你好啊"}}></Link>
Copy after login

Recommended learning: "react video tutorial"

The above is the detailed content of How to achieve page jump without recording 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template