What am I doing wrong?
Why doesn’t it go to the page "/block/:blockNumber/transactions"
constantly hits the page "/block/:blockNumber"
.
I tried it in different ways, but I don’t understand why it doesn’t go to the right page
<Route element={<Layout />}>
<Route path={RoutesEnum.root} element={<HomePage />} />
<Route
{...breadcrumbs.txPage}
path={'transaction/:txHash'}
element={<TransactionPage />}
/>
<Route
{...breadcrumbs.blockPage}
path={'block/:blockNumber'}
element={<BlockPage />}
>
<Route
{...breadcrumbs.blockTransactionsPage}
path={'transactions'}
element={<BlockTransactionsPage />}
/>
</Route>
<Route
{...breadcrumbs.addressPage}
path={'address/:address'}
element={<AddressPage />}
/>
<Route path={'transactions'} element={<TransactionsPage />} />
<Route path={'blocks'} element={<BlocksPage />} />
</Route>
2
Answers
You can try like this
Its happening because you are not using * after your parent route. Using "*" defines that all routes that are starting with "block/:blockNumber" will go to its defined children.
If the
BlockPage
component is supposed to be a layout route component then it necessarily needs to render anOutlet
component for nested routes to render their content into, just like theLayout
component.Example:
If the
BlockPage
component is not supposed to be a layout route component, i.e. it should be rendered on it’s own route, then theBlockTransactionsPage
route should be unnested.