Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tutorial.md #9430

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/start/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,7 @@ createBrowserRouter([
errorElement: <ErrorPage />,
children: [
{
action: rootAction,
errorElement: <ErrorPage />,
children: [
{ index: true, element: <Index /> },
Expand All @@ -1901,6 +1902,7 @@ createBrowserRouter([
```

When any errors are thrown in the child routes, our new pathless route will catch it and render, preserving the root route's UI!
Small gotcha, note that we had to add the rootAction. Otherwise, creating a new user won't work.

## JSX Routes

Expand All @@ -1921,7 +1923,10 @@ const router = createBrowserRouter(
action={rootAction}
errorElement={<ErrorPage />}
>
<Route errorElement={<ErrorPage />}>
<Route
errorElement={<ErrorPage />}
action={rootAction}
>
<Route index element={<Index />} />
<Route
path="contacts/:contactId"
Expand Down