|
1 | 1 | import * as React from "react"; |
2 | | -import {Helmet} from "react-helmet"; |
3 | | -//import { Switch, Route, Redirect } from "react-router-dom"; |
4 | 2 | import Home from "./components/Home"; |
5 | 3 | import importedComponent, {ComponentLoader, loadableResource} from "react-imported-component"; |
6 | 4 |
|
7 | | -const Another = importedComponent(() => import(/* webpackChunkName: namedChunk-0 */"./components/Another")); |
| 5 | +const Another = importedComponent(() => import(/* webpackChunkName: namedChunk-0 */"./components/Another"), { |
| 6 | + LoadingComponent: () => <div>loading</div> |
| 7 | +}); |
8 | 8 | const Other1 = importedComponent(() => import(/* webpackChunkName: "namedChunk-1" */"./components/Other")); |
9 | 9 | const Other2 = importedComponent(() => import(/* webpackChunkName: "namedChunk-1" */"./components/OtherTween")); |
10 | 10 |
|
11 | | -importedComponent(() => import(/* webpackChunkName: namedChunk-0 */"./components/Another"), { |
12 | | - render(Component, state) { |
13 | | - if (state.state === "loading") { |
| 11 | +const AnotherWrapped = importedComponent(() => import(/* webpackChunkName: namedChunk-0 */"./components/Another"), { |
| 12 | + render(Component, state, props: {prop: number}) { |
| 13 | + if (state === "loading") { |
14 | 14 | return <span/> |
15 | 15 | } |
16 | | - return <div><Component/></div> |
| 16 | + return <div className="wrapped"><Component test={props.prop} p2={props.prop}/></div> |
17 | 17 | } |
18 | 18 | }); |
19 | 19 | //import Another from "./components/Another"; |
20 | 20 |
|
21 | 21 | export default function App() { |
22 | 22 | return ( |
23 | 23 | <div> |
| 24 | + [not-trackable] |
24 | 25 | <ComponentLoader |
25 | 26 | loadable={() => import('./components/Another')} |
26 | 27 | /> |
27 | 28 | <ComponentLoader |
28 | 29 | loadable={loadableResource(() => import('./components/Another'))} |
29 | 30 | /> |
30 | | - <Helmet defaultTitle="Hello World!"> |
31 | | - <meta charSet="utf-8"/> |
32 | | - </Helmet> |
33 | | - <Home/> |
34 | | - <Another/> |
35 | | - <Other1/> |
| 31 | + [/not-trackable] |
| 32 | + [home]<Home/>[/home] |
| 33 | + <Another test={42} p2={42}/> |
| 34 | + [ |
| 35 | + <AnotherWrapped prop={24}/> |
| 36 | + ] |
| 37 | + <Other1 test={42}/> |
36 | 38 | <Other2/> |
37 | 39 | <Home/> |
38 | 40 | </div> |
|
0 commit comments