how to use redirect in react
import { Route, Redirect } from 'react-router'
<Route exact path="/" render={() => (
loggedIn ? (
<Redirect to="/dashboard"/>
) : (
<PublicHomePage/>
)
)}/>state = { redirect: null };
render() {
if (this.state.redirect) {
return <Redirect to={this.state.redirect} />
}
return(
// Your Code goes here
)
}
// update the redirect
this.setState({ redirect: "/someRoute" });state = { redirect: null };
render() {
if (this.state.redirect) {
return <Redirect to={this.state.redirect} />
}
return(
// Your Code goes here
)
}
<Redirect to="/somewhere/else" />
from django.shortcuts import redirectimport { useHistory } from "react-router-dom";
function App() {
let history = useHistory();
}
Also in JavaScript:
- javascript if array key exists
- paper material ui improt
- jquery disable enter key submit
- html shortcuts in jsx
- javascript array filter elements greater than
- how to run a vue js hello world app in vue version 3
- Javascript check if undefined
- node js http request get parameters
- jquery show password
- password validation with regular expression in javascript
- discord.js send message to specific channel
- javascript method to see if item exists in array
- array find javascript
- position of the mouse cursor javascript
- ScrollController not attached to any scroll views
- how to add onclick event in javascript
- javascript stringify an object
- append before parent jquery
- Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.ts(1219) angular
- get value in maps loop using enzym
- dimensions react native
- json stringify pretty
- javascript alert
- js replace all symbols in string