J
J
jslby2019-06-11 21:32:08
JavaScript
jslby, 2019-06-11 21:32:08

How to remove match.params from the router when redirecting?

My routes look like this:

const routes = [
  {
    path: '/',
    component: Home,
  },
  {
    path: '/chat',
    component: Chat,
  },
  {
    path: '/chat/:action',
    component: Chat,
  }
];

When a user visits the /chat/success URL, he is redirected to /chat like this: Then the dialogue goes on and he gets a similar link again: /chat/success /chat, but the component still has match.params.action == 'success' I found a way out, do forceRefresh, but maybe there is some other way to clear match.params after history.push
history.push('/chat');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-06-11
@rockon404

I think, instead of parameters, nested routes are more suitable here. Parameters are usually used to work with dynamic content.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question