Skip to content

Commit 9d9cb33

Browse files
committed
rename to resolvePendingComponent
1 parent c5dc9f2 commit 9d9cb33

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

packages/solid-router/src/Match.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const Match = (props: { matchId: string }) => {
4444

4545
const route: () => AnyRoute = () => router.routesById[matchState()!.routeId]
4646

47-
const PendingComponent = () =>
47+
const resolvePendingComponent = () =>
4848
route().options.pendingComponent ?? router.options.defaultPendingComponent
4949

5050
const routeErrorComponent = () =>
@@ -94,7 +94,7 @@ export const Match = (props: { matchId: string }) => {
9494
fallback={
9595
// Don't show fallback on server when using no-ssr mode to avoid hydration mismatch
9696
router.isServer || resolvedNoSsr ? undefined : (
97-
<Dynamic component={PendingComponent()} />
97+
<Dynamic component={resolvePendingComponent()} />
9898
)
9999
}
100100
>
@@ -130,7 +130,7 @@ export const Match = (props: { matchId: string }) => {
130130
<Solid.Match when={resolvedNoSsr}>
131131
<Solid.Show
132132
when={!router.isServer}
133-
fallback={<Dynamic component={PendingComponent()} />}
133+
fallback={<Dynamic component={resolvePendingComponent()} />}
134134
>
135135
<MatchInner matchId={props.matchId} />
136136
</Solid.Show>
@@ -291,21 +291,18 @@ export const MatchInner = (props: { matchId: string }): any => {
291291
return router.getMatch(match().id)?._nonReactive.loadPromise
292292
})
293293

294-
// Display pending component if defined
295-
const pendingComponent =
294+
const FallbackComponent =
296295
route().options.pendingComponent ??
297296
router.options.defaultPendingComponent
298297

299-
if (pendingComponent) {
300-
return (
301-
<>
302-
<Dynamic component={pendingComponent} />
303-
{loaderResult()}
304-
</>
305-
)
306-
}
307-
308-
return <>{loaderResult()}</>
298+
return (
299+
<>
300+
{FallbackComponent ? (
301+
<Dynamic component={FallbackComponent} />
302+
) : null}
303+
{loaderResult()}
304+
</>
305+
)
309306
}}
310307
</Solid.Match>
311308
<Solid.Match when={match().status === 'notFound'}>

0 commit comments

Comments
 (0)