forked from gregberge/loadable-components
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
50 lines (45 loc) · 1.34 KB
/
App.js
File metadata and controls
50 lines (45 loc) · 1.34 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react'
import { ErrorBoundary } from 'react-error-boundary';
// eslint-disable-next-line import/no-extraneous-dependencies
import { lazy } from '@loadable/component'
import Html from './Html'
const A = lazy(() => import('./letters/A'))
const B = lazy(() => import('./letters/B'))
const C = lazy(() => import(/* webpackPreload: true */ './letters/C'))
const D = lazy(() => import(/* webpackPrefetch: true */ './letters/D'))
const E = lazy(() => import('./letters/E?param'), { ssr: false })
const X = lazy(props => import(`./letters/${props.letter}`))
const Sub = lazy(props => import(`./letters/${props.letter}/file`))
const RootSub = lazy(props => import(`./${props.letter}/file`))
const App = () => {
return (
<Html title="Hello">
<React.Suspense fallback="Loading">
<ErrorBoundary FallbackComponent={Error}>
<A />
<br />
<B />
<br />
<X letter="A" />
<br />
<X letter="F" />
<br />
<E />
<br />
<Sub letter="Z" />
<br />
<RootSub letter="Y" />
</ErrorBoundary>
</React.Suspense>
</Html>
)
}
function Error({ error }) {
return (
<div>
<h1>Application Error</h1>
<pre style={{ whiteSpace: 'pre-wrap' }}>{error.stack}</pre>
</div>
);
}
export default App