I have a page that validates a user and redirects them to a login page if validation is successful. However, the using redirect
the URL changes but the new page for Login
is not rendered. How can I get the new page to render?
App.js
var child;
render() {
if (this.state.toLogin && !this.state.mounted) {
<Route exact path="/Login" component={Login} />;
<Route exact strict path="/" render={({location}) => {
if (location.pathname === window.location.pathname) {
return <Redirect to="/Login"/>;
}
return null;
}}
return(
<div className="App">
<ReactCSSTransitionGroup
transitionName="remove"
transitionEnterTimeout={100}
transitionLeaveTimeout={100}>
{child}
</ReactCSSTransitionGroup>
</div>
);
}
Index.js
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
);
EDIT: Made changes as per answers but now the URL is not changing and the page is not rendering