Can anyone tell what happens when we use exact in routes file. And use history,push to that route?

29 views Asked by At
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.

1

There are 1 answers

0
Raj Kumar Kausik On

I tried history.goBack() And it worked for me as I wanted to go back one page.