Skip to content

Commit 2c8edf7

Browse files
authored
[Closes #11] Use lazy import of LeafletContainer with suspense (#13)
* lazy import * added suspense wrapper
1 parent 95331b5 commit 2c8edf7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

client/src/Home.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { Container, Title } from '@mantine/core';
22
import { Head } from '@unhead/react';
3-
import LeafletContainer from './Components/LeafletContainer';
3+
import { lazy, Suspense } from 'react';
44
import 'leaflet/dist/leaflet.css';
55

6+
const LeafletContainer = lazy(() => import('./Components/LeafletContainer'));
7+
68
function Home () {
79
return (
810
<>
@@ -12,7 +14,9 @@ function Home () {
1214
<Container fluid p={0}>
1315
<Title order={1} px='md' pt='md'>Pocket Gardens</Title>
1416
<div style={{ height: 'calc(100dvh - 60px)', minHeight: 400, width: '100%', overflow: 'hidden', position: 'relative', zIndex: 0 }}>
15-
<LeafletContainer />
17+
<Suspense fallback={<div>Loading map...</div>}>
18+
<LeafletContainer />
19+
</Suspense>
1620
</div>
1721
</Container>
1822
</>

0 commit comments

Comments
 (0)