nested router, root leads to 404
I wish have the waterfall effect on rendering parent -> child components but I'm facing an issue with the following configuration. When I navigate to
/flashcards
I get redirected to Page404
.
I've tried doing the same as the docs:
parent is a wrapper component and contains sub-components including it's root:
In my case, Flashcards
is the wrapper component
FlashcardsOverview
is the component which should render when navigating to /flashcards
and FlashcardCollectionsView
should render as a child component of FlashcardsOverview
when navigating to /flashcards/collection/:id
How can I achieve this?
Why does this configuration cause 404 ?2 Replies
A route component is either aFlashcardsOverview
is the component which should render when navigating to/flashcards
andFlashcardCollectionsView
should render as a child component of FlashcardsOverview when navigating to/flashcards/collection/:id
Layout
or a Leaf.
I'm not aware that one can operate as both.
I think you need something like this:
I suspect the design you are actually after is more like:
In FlashcardsOverview
you then use useSearchParams
(concept) to obtain searchParams['collection-id']
to determine whether or not to
display FlashcardCollectionsView(collectionId)
within FlashcardsOverview
.i think you can use a leaf route with empty path and a component that renders nothing so that the parent route can render