Skip to content

Commit d57a567

Browse files
committed
Add React.lazy sample
1 parent c6add95 commit d57a567

File tree

19 files changed

+81
-4
lines changed

19 files changed

+81
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
*.log

src/App.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import './App.css'
2-
import { Randomizer } from './Randomizer'
2+
//import { Randomizer } from './Randomizer'
3+
import {
4+
// DashboardEager,
5+
DashboardLazy,
6+
} from './Dashboard'
37

48
function App() {
59
return (
610
<div className="App">
7-
<Randomizer />
11+
<DashboardLazy />
812
</div>
913
)
1014
}

src/Dashboard/DashboardEager/DashboardEager.css

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react'
2+
import Item1 from '../shared/Item1'
3+
import Item2 from '../shared/Item2'
4+
import Item3 from '../shared/Item3'
5+
6+
import './DashboardEager.css'
7+
8+
export const DashboardEager = () => {
9+
return (
10+
<div>
11+
<Item1 />
12+
<Item2 />
13+
<Item3 />
14+
</div>
15+
)
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './DashboardEager'

src/Dashboard/DashboardLazy/DashboardLazy.css

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { Suspense } from 'react'
2+
import './DashboardLazy.css'
3+
4+
const Item1 = React.lazy(() => import('../shared/Item1'))
5+
const Item2 = React.lazy(() => import('../shared/Item2'))
6+
const Item3 = React.lazy(() => import('../shared/Item3'))
7+
8+
export const DashboardLazy = () => {
9+
return (
10+
<div>
11+
<Suspense fallback={<div>Загрузка...</div>}>
12+
<Item1 />
13+
</Suspense>
14+
<Suspense fallback={<div>Загрузка...</div>}>
15+
<Item2 />
16+
</Suspense>
17+
<Suspense fallback={<div>Загрузка...</div>}>
18+
<Item3 />
19+
</Suspense>
20+
</div>
21+
)
22+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './DashboardLazy'

src/Dashboard/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { DashboardLazy } from './DashboardLazy'
2+
// export { DashboardEager } from './DashboardEager'

src/Dashboard/shared/Item1/Item1.css

Whitespace-only changes.

0 commit comments

Comments
 (0)