export const updateData =
(data, history) => (dispatch, getState) => {
const promise = putRequest(`${url}`, data, dispatch, getState)
.then(() => {
history.push("/p/someroute/")
})
.catch((error) => {
setError(error, dispatch);
});
return promise;
};
The above code pushes the route to "/" homepage. and if i see console.log(history) there, i can see action as "REPLACE" instead of "PUSH".
Why this can happen?
<PrivateRoute
exact
path="/p/someroute/"
component={SomeComponent}
role={USER_ROLES.get("ADMIN")}
/>
This is my route code.
I tried placing debugger; above history.push, GOT ACTION AS PUSH. As soon as that line of code executes, ACTION converts to REPLACE, and routes to "/" home directory route.
I tried history.goBack() And it worked for me as I wanted to go back one page.