I want to redirect when the sign up is failed in react.
And I am using Mobx.
So there is a question about this.
When I search for redirect, the people says that use the below code.
this.props.history.push("/");
this works when it is in the his own component.
But in my case, i am running that inside of action of mobx store.
And then, this.props is not the props of routes component.
So I wonder how I can read history of route through mobx store.
Thank you so much!
// In the mobx store
@action submitSignIn = () => {
axios
.post('auth/join', { email: this.initialState.register.email })
.then((response) => {
if (response.data === true) {
this.props.history.push('/signin');
}
.catch((error) => {
console.log(error);
});
};