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/api/hooks/useOutletContext.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,3 +20,71 @@ Returns the parent route `<Outlet context>`.
20
20
useOutletContext(): Context
21
21
```
22
22
23
+
<details>
24
+
<summary>Type declaration</summary>
25
+
26
+
```tsx
27
+
declarefunction useOutletContext<
28
+
Context=unknown
29
+
>():Context;
30
+
```
31
+
32
+
</details>
33
+
34
+
Often parent routes manage state or other values you want shared with child routes. You can create your own [context provider](https://react.dev/learn/passing-data-deeply-with-context) if you like, but this is such a common situation that it's built-into `<Outlet />`:
If you're using TypeScript, we recommend the parent component provide a custom hook for accessing the context value. This makes it easier for consumers to get nice typings, control consumers, and know who's consuming the context value. Here's a more realistic example:
0 commit comments