F
F
faleaksey2018-11-15 06:31:09
JavaScript
faleaksey, 2018-11-15 06:31:09

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

2 answer(s)
F
Frozen Coder, 2018-11-15
@faleaksey

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.

A
Anatoly Zharov, 2018-11-15
@SeaBreeze876

react-router is great
https://reacttraining.com/react-router/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question