I am trying react router v6. As per react training blog, I have created object of routing and passed to useRoutes():
function SomeOtherElement() {
return <h1>add user</h1>;
}
const routes = [
{
path: 'app',
element: <DashboardLayout />,
children: [
{ path: 'account', element: <AccountView /> },
{
path: 'users', element: <UserListView />,
children: [
{ path: 'add', element: <SomeOtherElement /> }
]
},
{ path: 'dashboard', element: <DashboardView /> },
{ path: 'products', element: <ProductListView /> },
{ path: 'settings', element: <SettingsView /> },
{ path: '*', element: <Navigate to="/404" /> }
]
}];
const routing = useRoutes(routes);
But the nested routing is not working. As you can see in above object, I want to create URL and render the UI for user "add" functionality.
URL in the browser is getting updated correctly to http://localhost:3000/app/users/add but UI is not updating.