marmelab / marmelab/react-admin

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

Open
#10,892 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs more info
Dominant language
TypeScript
Stars
26.9k
Forks
5.5k
Avg merge
2d 3h
Merged PRs (30d)
19

Description

**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:
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:

```tsx
function MyComp() {
const location = useLocation()

return (
}
key={location.key}
>


)
}

```

**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):

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/ra-ui-materialui/src/layout/Layout.tsx around the Suspense boundary linked in the issue, then reproduce the lazy-route navigation with a slow network after upgrading to react-router v7. Compare the behavior with the linked react-router strategy; done means the LoadingComp fallback is initiated while the lazy component loads.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.