Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting to subpage with id

I've had two routes:

<Route path="/client/:id/members" component={Members} />
<Route path="/client/:id/members/:mid" component={MemberProfile} />

why when I'm trigger:

window.location.href = `/client/${id}/members/${mid}`;

then my url is changed to correct form like in the route path but not redirect me to MemberProfile component?

Thanks for any help!

like image 732
BokuNoHeeeero Avatar asked Oct 26 '25 05:10

BokuNoHeeeero


1 Answers

as

<Route path="/client/:id/members" component={Members} />

declared before

<Route path="/client/:id/members/:mid" component={MemberProfile} />

and

/client/${id}/members/${mid}

fit

"/client/:id/members"

Members component will still be rendered.

Consider one of the following:

  1. decleare MemberProfile before Members

  2. change MembersProfile route to /client/:id/member/:mid for example

  3. use exact Route property

like image 185
Hagai Harari Avatar answered Oct 27 '25 19:10

Hagai Harari