'Why are my nested route components not rendering in react-router-dom 6?

I have the following routes in my App.tsx file:

import { default as Collections } from './pages/collections/Root';

<Routes>
    <Route path="/" element={<Home />} />
    <Route path="/collections/*" element={<Collections />} />
</Routes>

And this is what I have in my Collections file:

const Root = () => {
    return (
        <>
            <DocumentTitle title="Collections" />

            <Navbar baseUrl="/collections" />

            <Routes>
                <Route path="/collections" element={<Collections />} />
                <Route path="/collections/create" element={<AddCollection />} />
                <Route path="/collections/categories" element={<Categories />} />
                <Route path="/collections/edit/:collectionId" element={<EditCollection />} />
                <Route path="/collections/addItems/:collectionId" element={<ManageCollectionItems />} />
            </Routes>
        </>
    );
};

export default Root;

When I visit the /collections URL, I can see that the document title and navbar have loaded in the DOM, however, I don't see any of my nested routes and I'm also not receiving any errors or warnings.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source