react redirect in code code example
Example 1: navigating programatically react
import { Route } from 'react-router-dom'
const Button = () => (
<Route render={({ history}) => (
<button
type='button'
onClick={() => { history.push('/new-location') }}
>
Click Me!
</button>
)} />
)
Example 2: how to use redirect in react
import { useHistory } from "react-router-dom";
function App() {
let history = useHistory();
}