Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/solid-router/src/Match.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,15 @@ export const Match = (props: { matchId: string }) => {
? resolvedNoSsr
: currentMatchState().ssr === 'data-only'

const ResolvedSuspenseBoundary = () => Solid.Suspense
const ResolvedSuspenseBoundary = () =>
route().options.wrapInSuspense === false
? SafeFragment
: (route().options.wrapInSuspense ??
(resolvePendingComponent() ||
(route().options.errorComponent as any)?.preload ||
resolvedNoSsr))
? Solid.Suspense
: SafeFragment

const ResolvedCatchBoundary = () =>
routeErrorComponent() ? CatchBoundary : SafeFragment
Expand Down
31 changes: 31 additions & 0 deletions packages/solid-router/tests/Matches.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,37 @@ test('should show pendingComponent of root route', async () => {
expect(await rendered.findByTestId('root-content')).toBeInTheDocument()
})

test('wrapInSuspense false prevents route pendingComponent suspense fallback', async () => {
const gate = createControlledPromise<void>()
const history = createMemoryHistory({ initialEntries: ['/posts'] })
const root = createRootRoute({
component: () => <Outlet />,
})
const postsRoute = createRoute({
getParentRoute: () => root,
path: '/posts',
wrapInSuspense: false,
pendingComponent: () => <div data-testid="posts-pending">Loading</div>,
loader: () => gate,
component: () => <div>Posts content</div>,
})

const router = createRouter({
routeTree: root.addChildren([postsRoute]),
history,
defaultPendingMs: 0,
})

render(() => <RouterProvider router={router} />)

await waitFor(() => expect(router.state.status).toBe('pending'))
expect(screen.queryByTestId('posts-pending')).not.toBeInTheDocument()

gate.resolve()

expect(await screen.findByText('Posts content')).toBeInTheDocument()
})

test('useMatchRoute follows superseding pending locations', async () => {
const aGate = createControlledPromise<void>()
const bGate = createControlledPromise<void>()
Expand Down