Skip to content

Commit 70b64e2

Browse files
committed
fix(react-router): fix ClientDataFunctionArgs' context
1 parent b7b1876 commit 70b64e2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.changeset/tasty-beers-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
Fix `ClientDataFunctionArgs`' `context`

packages/react-router/lib/types/route-module.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,13 @@ type ClientDataFunctionArgs<T extends RouteInfo> = {
141141
**/
142142
params: T["params"];
143143
/**
144-
* When `future.unstable_middleware` is not enabled, this is undefined.
145-
*
146-
* When `future.unstable_middleware` is enabled, this is an instance of
147-
* `unstable_RouterContextProvider` and can be used to access context values
148-
* from your route middlewares. You may pass in initial context values in your
149-
* `<HydratedRouter unstable_getContext>` prop
144+
* This is a `RouterContextProvider` instance generated from your router's
145+
* `unstable_getContext` function and/or populated from route middleware
146+
* functions.
150147
*/
151-
context: unstable_RouterContextProvider;
148+
context: MiddlewareEnabled extends true
149+
? unstable_RouterContextProvider
150+
: undefined;
152151
};
153152

154153
type ServerDataFunctionArgs<T extends RouteInfo> = {

0 commit comments

Comments
 (0)