-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
38 lines (33 loc) · 1.02 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import path from 'path'
import React from 'react'
import universal from 'react-universal-component'
import styles from '../css/App.css'
const UniversalExample = universal(() => import('./Example'), {
path: path.resolve(__dirname, './Example'),
resolve: () => require.resolveWeak('./Example'),
minDelay: 500
})
export default class App extends React.Component {
// set `show` to `true` to see dynamic chunks served by initial request
// set `show` to `false` to test how asynchronously loaded chunks behave,
// specifically how css injection is embedded in chunks + corresponding HMR
state = {
show: true
}
componentDidMount() {
if (this.state.show) return
setTimeout(() => {
console.log('now showing <Example />')
this.setState({ show: true })
}, 1000)
}
render() {
return (
<div>
<h1 className={styles.title}>Hello World</h1>
{this.state.show && <UniversalExample />}
{!this.state.show && 'Async Component Not Requested Yet'}
</div>
)
}
}