Home >Web Front-end >Front-end Q&A >How to achieve page jump without recording in react
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.
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");
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>
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!