`How to get path without dynamic parameters in react-router?
M
M
Mad Coder2021-06-11 17:11:02
React
Mad Coder, 2021-06-11 17:11:02

How to get path without dynamic parameters in react-router?

There is a route

<Route path={`user/yourself/expert/:idPage?`} Component={Users} />

the dynamic part of the :idPage route is pagination.
how do i get the path without the dynamic part i.e. in this case "user/yourself/expert/"
Tried via const { search, pathname } = useLocation(); however pathname points to the whole path with pagination

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question