Packages
"react": "^15.5.4",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"webpack": "^2.4.1"
The function that is supposed to redirect user to a new location:
successfullySignedUp()
{
let userData = this.props.signUpResult.signUpData;
this.saveLocalUserToBrowser(userData);
console.log('login success', userData); // -> successful
return (<Redirect to="/about"/>); == -> No response from command
}
I've tried other options like,
return (<Redirect to={{ pathname: '/login' }}/>);
return (<Redirect push to="/somewhere/else"/>);
<Switch>
<Redirect from='/old-path' to='/new-path'/>
<Route path='/new-path' component={Place}/>
</Switch>
I've seen examples of Redirect
being imported from react-router
and react-router-dom
both of which don't work in my case.
I've defined my routes in Layout class:
class Layout extends React.Component
{
render()
{
return (
<Provider store={store}>
<BrowserRouter>
<Switch>
<Route path="/about/test" component={AboutPage} />
<Route path="/how-it-works" component={HowItWorksPage} />
<Route path="/all-restaurants" component={AllRestaurantsPage} />
<Route path="/restaurant" component={RestaurantPage} />
<Route path="/faq" component={FAQPage} />
<Route path="/login" component={LoginPage} />
<Route path="/register" component={SignupPage} />
<Route path="/" component={HomePage} />
<Route path="/home" component={HomePage} />
</Switch>
</BrowserRouter>
</Provider>
)
}
}
and implemented it in index.js:
ReactDOM.render
(
<Layout />,
document.getElementById('app')
);