how to move to another page in react code example
Example 1: how to redirect react router from the app components
state = { redirect: null };
render() {
if (this.state.redirect) {
return <Redirect to={this.state.redirect} />
}
return(
)
}
this.setState({ redirect: "/someRoute" });
Example 2: how to redirect react router from the app components
state = { redirect: null };
render() {
if (this.state.redirect) {
return <Redirect to={this.state.redirect} />
}
return(
)
}
Example 3: react window navigate
window.location.href = "/insert/your/path/here".