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
Fix types for `UIMatch` to reflect that the `loaderData`/`data` properties may be `undefined`
6
+
7
+
- When an `ErrorBoundary` is being rendered, not all active matches will have loader data available, since it may have been their `loader` that threw to trigger the boundary
8
+
- The `UIMatch.data` type was not correctly handing this and would always reflect the presence of data, leading to the unexpected runtime errors when an `ErrorBoundary` was rendered
9
+
- ⚠️ This may cause some type errors to show up in your code for unguarded `match.data` accesses - you should properly guard for `undefined` values in those scenarios.
10
+
11
+
```tsx
12
+
// app/root.tsx
13
+
exportfunction loader() {
14
+
someFunctionThatThrows(); // ❌ Throws an Error
15
+
return { title: "My Title" };
16
+
}
17
+
18
+
exportfunction Layout({ children }: { children:React.ReactNode }) {
19
+
let matches =useMatches();
20
+
let rootMatch =matches[0] asUIMatch<Awaited<ReturnType<typeofloader>>>;
21
+
// ^ rootMatch.data is incorrectly typed here, so TypeScript does not
22
+
// complain if you do the following which throws an error at runtime:
0 commit comments