Skip to content

Instantly share code, notes, and snippets.

@arinthros
Created November 23, 2021 02:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arinthros/8312245cdcba27cd0828ca1f13720588 to your computer and use it in GitHub Desktop.
Save arinthros/8312245cdcba27cd0828ca1f13720588 to your computer and use it in GitHub Desktop.
React Router v6 nesting example
import { Route, Routes } from 'react-router-dom'
function AppRoutes() {
return (
<Routes>
<Route index={true} element={<Home />} />
<Route path="settings" element={<Settings />}>
<Route path="people" element={<PeopleSettings />}>
<Route path=":userId" element={<PersonSettings />} />
</Route>
<Route path="types" element={<TypesSettings />}>
<Route path=":typeId" element={<TypeSettings />} />
</Route>
<Route path="security" element={<SecuritySettings />} />
</Route>
<Route path="items/:storageId" element={<Storage />}>
<Route path=":itemId" element={<StorageItem />} />
</Route>
</Routes>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment