You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/start/framework/route-module.md
+35-1
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ This guide is a quick overview of every route module feature. The rest of the ge
25
25
26
26
## Component (`default`)
27
27
28
-
Defines the component that will render when the route matches.
28
+
The `default` export in a route module defines the component that will render when the route matches.
29
29
30
30
```tsx filename=app/routes/my-route.tsx
31
31
exportdefaultfunction MyRouteComponent() {
@@ -40,6 +40,40 @@ export default function MyRouteComponent() {
40
40
}
41
41
```
42
42
43
+
### Props passed to the Component
44
+
45
+
When the component is rendered, it is provided the props defined in `Route.ComponentProps` that React Router will automatically generate for you. These props include:
46
+
47
+
1.`loaderData`: The data returned from the `loader` function in this route module
48
+
2.`actionData`: The data returned from the `action` function in this route module
49
+
3.`params`: An object containing the route parameters (if any).
50
+
4.`matches`: An array of all the matches in the current route tree.
51
+
52
+
You can use these props in place of hooks like `useLoaderData` or `useParams`. This may be preferrable because they will be automatically typed correctly for the route.
Route loaders provide data to route components before they are rendered. They are only called on the server when server rendering or during the build with pre-rendering.
0 commit comments