redirect push react 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: redirect to in react js

<Route exact path="/">
  {loggedIn ? <Redirect to="/dashboard" /> : <PublicHomePage />}
</Route>

Example 3: redirect react router

<Redirect to="/somewhere/else" />

Example 4: import redirect

from django.shortcuts import redirect