Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit e8a87bf

Browse files
authored
Upgrading to webpack v4.28.2 to support dynamic imports (#86)
* upgrading to webpack v4.28.2 to support dynamic imports * dynamically import component in examples * move component
1 parent 5b69250 commit e8a87bf

File tree

5 files changed

+83
-135
lines changed

5 files changed

+83
-135
lines changed

examples/fancy/src/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Child from './child';
77
import './bg.css';
88
import './styles.less';
99

10+
const DynamicComponent = React.lazy(() => import('./dynamic'));
11+
1012
class App extends React.Component {
1113
state = {
1214
counter: 0
@@ -45,6 +47,9 @@ class App extends React.Component {
4547
Does it leak SECRET_TOKEN:{' '}
4648
{process.env.SECRET_TOKEN === undefined ? 'No' : 'Yes'}
4749
</p>
50+
<React.Suspense fallback={<div>Loading dynamic component...</div>}>
51+
<DynamicComponent />
52+
</React.Suspense>
4853
<p>Background image snowflake:</p>
4954
<div className="snowflake" style={{ height: 300, width: 300 }} />
5055
<p>Real image snowflake:</p>
@@ -53,6 +58,7 @@ class App extends React.Component {
5358
The library <code>p-finally</code> is not ES5, so this page should
5459
throw an error in older browsers like IE11.
5560
</p>
61+
5662
</div>
5763
);
5864
}

examples/fancy/src/dynamic.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
3+
function Dynamic() {
4+
return (
5+
<div className="dynamic">I was loaded dynamically</div>
6+
)
7+
}
8+
9+
export default Dynamic;

examples/fancy/src/styles.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
body {
55
color: @light-blue;
66
}
7+
.dynamic {
8+
background: lightseagreen;
9+
color: #333;
10+
border-radius: 6px;
11+
padding: 6px;
12+
}

0 commit comments

Comments
 (0)