Skip to content

<Suspense/> <Await/> not working as expected #14372

@anapeksha

Description

@anapeksha

Reproduction

I am using RR v7 in framework mode to build an SPA with clientLoader & clientAction
Wrap any <Outlet/> with <Suspense/> to implement a local loading state which is unique per route.

The main problem is I can safely create a global navigation loader with useNavigation(). But, I fail to create local loaders with Suspense & Await, the navigations are taking place without any loader appearing.

  • I am correctly returning axios promises and am making sure that none of the calls are awaited along the way
  • The API calls are correctly executing and is being cancelled through AbortController of request.signal in clientLoader

Implementation example:

In the layout

<Suspense fallback={<Loader />}>
     <Outlet />
</Suspense>
<Await resolve={loaderData}>
     {(data) => (<></>)}
</Await>
export async function clientLoader({
  request,
  params,
}: Route.ClientLoaderArgs) {
  const httpService = new HttpService();
  const { organizationId } = params;
  const {
    skip = 0,
    take = 10,
    query,
  } = Object.fromEntries(new URL(request.url).searchParams.entries());

  return httpService.post<IUserPaginatedLoaderData>(
    `/organizations/${organizationId}/users/query`,
    {
      skip,
      take,
      query,
    },
    {
      signal: request.signal,
    },
  );
}

System Info

System:
    OS: macOS 15.6.1
    CPU: (8) arm64 Apple M2
    Memory: 138.28 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.19.0 - /opt/homebrew/bin/node
    npm: 10.9.3 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 140.0.7339.133
    Safari: 18.6
  npmPackages:
    @react-router/dev: ^7.8.1 => 7.8.1 
    @react-router/node: ^7.8.1 => 7.8.1 
    @react-router/serve: ^7.8.1 => 7.8.1 
    react-router: ^7.8.1 => 7.8.1 
    vite: ^6.3.5 => 6.3.5

Used Package Manager

npm

Expected Behavior

The local loaders should show while navigating between routes and clientLoader for next route is being called.

Actual Behavior

No loaders are shown at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions