hello i’m new to react and react router i have exercice page contain multiple exercices so when i click an exrcice i can get individual exercice
<Link to={`exercice/${item.id}`} exact path={`exercice/${item.id}`} className={MenuCard.menu}>
with path like this
http://localhost:3000/exercice/0002
and i have pricing page wich contain exerice component so when i click an exercice from pricing page i get
http://localhost:3000/pricing/exercice/0002
wich goes to nothing
how i can get
http://localhost:3000/exercice/0002
thank you
>Solution :
You need to add a / at the beginning of your paths so the links are not relative to the current route. As stated in the documentation:
A relative
<Link to>value (that does not begin with/) resolves relative to the parent route, which means that it builds upon the URL path that was matched by the route that rendered that<Link>.