actually, I have 2 questions.
How can I pass multiple parameters to a route
I'm getting undefined with this code; how can I receive my parameters.
const { name, family } = useParams();
I searched for my problem and most answers here are for class components and react router v5
. so they didn't work for me.
I have a button, and when I click on it, the useNavigate
function runs like this:
onClick={() => {
HandleFetchListServiceConfer();
navigate({
pathname: "/SetServiceConfer",
search: `${name}&${family}`,
});
}}
as you can see I add name
and family
to my route. but when I'm going to receive it in my useParams
. it doesn't work. it return an empty object.
and about my first question. by adding multiple parameters, I meant when you don't use useNavigate
and you want to pass parameters in Route.
I tried something like this:
<Route
path="/SetServiceConfer/:name/:family"
element={<ListServiceConfer />}
/>
it destroys entire path. I got not matching routes found
The answer linked here is unrelated. I get undefined
with this answer.