File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @remix-run/router " : patch
3
+ ---
4
+
5
+ Support ` unstable_dataStrategy ` on ` staticHandler.queryRoute `
Original file line number Diff line number Diff line change @@ -2628,5 +2628,18 @@ describe("ssr", () => {
2628
2628
2629
2629
/* eslint-enable jest/no-conditional-expect */
2630
2630
} ) ;
2631
+
2632
+ describe ( "router dataStrategy" , ( ) => {
2633
+ it ( "should apply a custom data strategy" , async ( ) => {
2634
+ let { queryRoute } = createStaticHandler ( SSR_ROUTES ) ;
2635
+ let data ;
2636
+
2637
+ data = await queryRoute ( createRequest ( "/custom" ) , {
2638
+ unstable_dataStrategy : urlDataStrategy ,
2639
+ } ) ;
2640
+ expect ( data ) . toBeInstanceOf ( URLSearchParams ) ;
2641
+ expect ( ( data as URLSearchParams ) . get ( "foo" ) ) . toBe ( "bar" ) ;
2642
+ } ) ;
2643
+ } ) ;
2631
2644
} ) ;
2632
2645
} ) ;
Original file line number Diff line number Diff line change @@ -412,7 +412,11 @@ export interface StaticHandler {
412
412
) : Promise < StaticHandlerContext | Response > ;
413
413
queryRoute (
414
414
request : Request ,
415
- opts ?: { routeId ?: string ; requestContext ?: unknown }
415
+ opts ?: {
416
+ routeId ?: string ;
417
+ requestContext ?: unknown ;
418
+ unstable_dataStrategy ?: DataStrategyFunction ;
419
+ }
416
420
) : Promise < any > ;
417
421
}
418
422
@@ -3099,7 +3103,12 @@ export function createStaticHandler(
3099
3103
{
3100
3104
routeId,
3101
3105
requestContext,
3102
- } : { requestContext ?: unknown ; routeId ?: string } = { }
3106
+ unstable_dataStrategy,
3107
+ } : {
3108
+ requestContext ?: unknown ;
3109
+ routeId ?: string ;
3110
+ unstable_dataStrategy ?: DataStrategyFunction ;
3111
+ } = { }
3103
3112
) : Promise < any > {
3104
3113
let url = new URL ( request . url ) ;
3105
3114
let method = request . method ;
@@ -3132,7 +3141,7 @@ export function createStaticHandler(
3132
3141
location ,
3133
3142
matches ,
3134
3143
requestContext ,
3135
- null ,
3144
+ unstable_dataStrategy || null ,
3136
3145
false ,
3137
3146
match
3138
3147
) ;
You can’t perform that action at this time.
0 commit comments