@@ -2,6 +2,7 @@ import type {
22 ActivityDefinition ,
33 RegisteredActivityName ,
44} from "@stackflow/config" ;
5+ import { isPromiseLike } from "__internal__/utils/isPromiseLike" ;
56import type { ActivityComponentType } from "../../__internal__/ActivityComponentType" ;
67import type { StackflowReactPlugin } from "../../__internal__/StackflowReactPlugin" ;
78import { isStructuredActivityComponent } from "../../__internal__/StructuredActivityComponentType" ;
@@ -20,10 +21,7 @@ export function loaderPlugin<
2021 } ,
2122> (
2223 input : StackflowInput < T , R > ,
23- loadData : (
24- activityName : string ,
25- activityParams : { } ,
26- ) => SyncInspectablePromise < unknown > ,
24+ loadData : ( activityName : string , activityParams : { } ) => unknown ,
2725) : StackflowReactPlugin {
2826 return ( ) => {
2927 return {
@@ -62,12 +60,16 @@ export function loaderPlugin<
6260
6361 const loaderData = loadData ( activityName , activityParams ) ;
6462
65- Promise . allSettled ( [ loaderData ] ) . then ( ( [ loaderDataPromiseResult ] ) => {
66- printLoaderDataPromiseError ( {
67- promiseResult : loaderDataPromiseResult ,
68- activityName : matchActivity . name ,
69- } ) ;
70- } ) ;
63+ if ( isPromiseLike ( loaderData ) ) {
64+ Promise . allSettled ( [ loaderData ] ) . then (
65+ ( [ loaderDataPromiseResult ] ) => {
66+ printLoaderDataPromiseError ( {
67+ promiseResult : loaderDataPromiseResult ,
68+ activityName : matchActivity . name ,
69+ } ) ;
70+ } ,
71+ ) ;
72+ }
7173
7274 return {
7375 ...event ,
@@ -95,10 +97,7 @@ function createBeforeRouteHandler<
9597 } ,
9698> (
9799 input : StackflowInput < T , R > ,
98- loadData : (
99- activityName : string ,
100- activityParams : { } ,
101- ) => SyncInspectablePromise < unknown > ,
100+ loadData : ( activityName : string , activityParams : { } ) => unknown ,
102101) : OnBeforeRoute {
103102 return ( {
104103 actionParams,
@@ -116,7 +115,7 @@ function createBeforeRouteHandler<
116115 }
117116
118117 const loaderData =
119- matchActivity . loader && loadData ( activityName , activityParams ) ;
118+ matchActivity . loader && resolve ( loadData ( activityName , activityParams ) ) ;
120119 const lazyComponentPromise = resolve (
121120 isStructuredActivityComponent ( matchActivityComponent ) &&
122121 typeof matchActivityComponent . content === "function"
0 commit comments