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

[Demo] Add lazy loading to CRM demo to illustrate code splitting #9255

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/crm/src/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { HtmlHTMLAttributes } from 'react';
import React, { Suspense, HtmlHTMLAttributes } from 'react';
import { CssBaseline, Container } from '@mui/material';
import { CoreLayoutProps, CheckForApplicationUpdate } from 'react-admin';
import { ErrorBoundary } from 'react-error-boundary';

import { Error } from 'react-admin';
import { Error, Loading } from 'react-admin';
import Header from './Header';

const Layout = ({ children }: LayoutProps) => (
Expand All @@ -14,7 +14,7 @@ const Layout = ({ children }: LayoutProps) => (
<main id="main-content">
{/* @ts-ignore */}
<ErrorBoundary FallbackComponent={Error}>
{children}
<Suspense fallback={<Loading />}>{children}</Suspense>
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we shouldn't do that by default on all our layouts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably

</ErrorBoundary>
</main>
</Container>
Expand Down
4 changes: 3 additions & 1 deletion examples/crm/src/deals/DealList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { DealShow } from './DealShow';
import { OnlyMineInput } from './OnlyMineInput';
import { typeChoices } from './types';

export const DealList = () => {
const DealList = () => {
const { identity } = useGetIdentity();
const location = useLocation();
const matchCreate = matchPath('/deals/create', location.pathname);
Expand Down Expand Up @@ -61,3 +61,5 @@ const DealActions = () => {
</TopToolbar>
);
};

export default DealList;
3 changes: 2 additions & 1 deletion examples/crm/src/deals/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable import/no-anonymous-default-export */
import { DealList } from './DealList';
import * as React from 'react';
const DealList = React.lazy(() => import('./DealList'));

export default {
list: DealList,
Expand Down