Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to retrieve current path

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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>.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading