Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lazy-loaded React components #9260

Merged
merged 5 commits into from
Sep 8, 2023
Merged

Add support for lazy-loaded React components #9260

merged 5 commits into from
Sep 8, 2023

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Sep 7, 2023

Problem

To use lazy-loaded commponents as Resource routes, developers must override the default layout to add <Suspense>.

Solution

  • include <Suspense> in the default layout
  • move the rendering delay to <Loading> so that it can be used directly as Suspense fallback
  • tweak Loading UI to make it less ugly

Capture d’écran 2023-09-07 à 17 57 17

@fzaninotto fzaninotto added the RFR Ready For Review label Sep 7, 2023
expect(screen.queryByText('PostList')).not.toBeNull()
);
});
it('should show a loader when requireAuth is true and dataProvider.checkAuth() takes more than 1s to reply', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was testing that CoreAdminRouter displays the loader only after 1s. Now, this feature has moved to the Loader itself.

@@ -340,7 +309,7 @@ describe('<CoreAdminRoutes>', () => {
</CoreAdminContext>
);
expect(screen.queryByText('PostList')).toBeNull();
expect(screen.queryByText('Loading')).toBeNull();
expect(screen.queryByText('Loading')).not.toBeNull();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no delay, the test loader (which is NOT our <Loading> component) is shown right away

@fzaninotto fzaninotto added WIP Work In Progress and removed RFR Ready For Review labels Sep 7, 2023
@djhi djhi added this to the 4.14.0 milestone Sep 8, 2023
@djhi djhi merged commit 0d2fe46 into next Sep 8, 2023
8 checks passed
@djhi djhi deleted the loading-async branch September 8, 2023 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants