I want to redirect my app from "/" to "/login" by using Redirect.
There is my code:
import React, { Component } from 'react'
import { Route, Switch, Redirect, withRouter } from 'react-router-dom'
import Login from './Login'
@withRouter
export default class Routes extends Component {
render() {
return (
<>
<Switch>
<Redirect exact from="/" to="/login" />
<Route path="/login" component={Login} />
</Switch>
</>
)
}
}
On first render url changind but {Login} component doesn't render.
BUT when I reloading the page, {Login} component rendering, and all work correctly.
(for more info) This component nested in Router with history prop.
Can anyone please help me find where is trouble?
EDITED: delete 'push' from Redirect, still doesn't work