Answer the question
In order to leave comments, you need to log in
Nested routes in React?
Hello! How is it possible to implement the following:
home/category/subcategory/product ?
at the same time, if we display a popular product on the main page, when you click on it in the url, display the entire path to the file?
category and subcategory are not just a static url, but child components...
Are there any examples or ready-made solutions? thank)
Answer the question
In order to leave comments, you need to log in
If we are talking about react-router, then we can use it to make several nested Switches. Those. somewhere at the top we have the main Switch, the routes of which lead to the category components at the initial url like 'home/:category', in this or these category components there is another Switch, the routes of which lead to the subcategory component(s), where there is more one Switch. Something like this. Here the details depend on how these child components are made - one per category or one per all categories.
react-router is great
https://reacttraining.com/react-router/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question