There is a need to push to a specific location say '/login' based on statuses inside interceptor.
Is there a way to directly push to a location?
There is a need to push to a specific location say '/login' based on statuses inside interceptor.
Is there a way to directly push to a location?
A quick and ugly way could be. window.location.replace('/myUrl')
UPDATE
A WorkAround could be
/**RootComponent*/
export const myRouter = {};
@withRouter()
Class RootComponent extends React.Component {
constructor(props) {
super(props);
myRouter = this.props.router;
}
render() {
return <Provider store={store}>
<MainComponent/>
</Provider>
}
}
/**Interceptor*/
import { myRouter } from 'RootComponent';
if (status == 401) {
myRouter.push('/myUrl');
}