react-routerreact-router-v4react-router-reduxreact-router-dom

react-router Redirect vs history.push


I was reading react-router-redux examples and I confused, what is the difference beetween:

import { Redirect } from 'react-router-dom'

...

<Redirect to='/login' /> 

and

import { push } from 'react-router-redux'

...

push('/login')

Solution

  • Redirect

    Rendering a <Redirect> will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do.

    whereas History

    push function Pushes a new entry onto the history stack