Loading for lazy-load strategy is not showing in react-router v7
Author: lukascivilCreated Aug 24, 2025Updated Apr 30, 2026
Labelsneeds more info
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:
- Create router that import lazy components;
- Navigate with slow network to understand the problem, setted in the Browser;
- Loading componente will not be initiated by RA Suspense;
This strategy solved my problem: https://github.com/remix-run/react-router/issues/12474
I think that we can put key inside the Suspense to solve the problem: https://github.com/marmelab/react-admin/blob/377f29f0c4357281838e978fa613acb29c6dbe2b/packages/ra-ui-materialui/src/layout/Layout.tsx#L70
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):
Source: marmelab/react-admin