Skip to content

Loading for lazy-load strategy is not showing in react-router v7 #10892

Description

@lukascivil

What you were expecting:
RA lazy strategy with loading should work properly after update to react-router v7.

What happened instead:

Loading component not initiate in Suspense when update my App to react-router v7.

Steps to reproduce:

  1. Create router that import lazy components;
  2. Navigate with slow network to understand the problem, setted in the Browser;
  3. Loading componente will not be initiated by RA Suspense;

This strategy solved my problem:
remix-run/react-router#12474

I think that we can put key inside the Suspense to solve the problem:

<Suspense fallback={<Loading />}>

like:

function MyComp() {
  const location = useLocation()

  return (
    <Suspense 
      fallback={<LoadingComp text="Loading..." />}
      key={location.key}
    >
      <MyAwaitOrUseComp />
    </Suspense>
  )
}

Other information:

Environment

  • React-admin version: 5.8.4
  • Last version that did not exhibit the issue (if applicable):
  • React version: v18
  • Browser: chrome
  • Stack trace (in case of a JS error):

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions