+ 1

how to render the sublist only when one of the routes inside is active?

const pages: Page = { termsPage: [ {name: 'First Page', path: '/one/two/'}, { name: 'Second Page', path: '/three/four/', routes: [ {name: 'subpage1', path: '/sub1/'}, {name: 'subpage2', path: '/sub2/'} ] }, {name: 'Third Page', path: '/five/six/'}, {name: 'Fourth Page', path: '/seven/eight/'}, {name: 'Fives Page', path: '/nine/ten/'} ]; }

1st Mar 2020, 10:07 AM
Ahmad
Ahmad - avatar
5 Antworten
+ 1
Ahmad check out how router routes the routes https://code.sololearn.com/WukMCoMDyUf6/?ref=app
2nd Mar 2020, 1:51 AM
Calviղ
Calviղ - avatar
+ 1
For nested routing, you could use useRouteMatch with useParams.
1st Mar 2020, 1:49 PM
Calviղ
Calviղ - avatar
+ 1
Ahmad Study the session of Nesed Routing, would help you to build the routes. https://reacttraining.com/react-router/web/guides/quick-start
1st Mar 2020, 3:50 PM
Calviղ
Calviղ - avatar
+ 1
Thanks @Calvin that was quite helpful.
2nd Mar 2020, 2:33 PM
Ahmad
Ahmad - avatar
0
@Vivek as you see in this function we have the siblings array routes inside of the secondPage, i want to see the sublist(routes) as i click on the second page and the it redirects to first sublist it becomes active.
1st Mar 2020, 10:49 AM
Ahmad
Ahmad - avatar