Change the pathname in history pathname in React

Viewed 842

I am redirecting the user using this:

history.push({
  pathname: `${pathname}/order`,
  search: qs.stringify({
    id,
    group,
  }),
})

In current page, pathname is /app/clients/group/active, which I am getting from location.

Now, I want to redirect the user to /data:

history.push({
  pathname: `${pathname}/data`,
  search: qs.stringify({
    id,
    group,
  }),
})

However, pathname has /active, which is not needed when redirecting to the /data route.

How can I remove it from the pathname as user is on that page.

0 Answers
Related