-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathindex.js
More file actions
90 lines (80 loc) · 2.29 KB
/
Copy pathindex.js
File metadata and controls
90 lines (80 loc) · 2.29 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import {
Header,
importComponent,
Miss,
render,
withServerData,
useServerData,
Status,
withConfig,
useConfig,
} from 'hops';
import React from 'react';
import { Link, Redirect, Route, Switch } from 'react-router-dom';
import { Helmet } from 'react-helmet-async';
import FlowText from './flow-text';
const Text = importComponent(() =>
import(/* webpackPrefetch: true */ './text')
);
const BoldText = importComponent(() =>
import(
// webpackPreload: true
'./bold-text'
)
);
const Images = importComponent(
() => import('./images'),
(mod) => mod.Images
);
const ServerDataHoC = withServerData(({ serverData }) => (
<output>{serverData.method}</output>
));
const ServerDataHook = () => {
const serverData = useServerData();
return <output>{serverData.method}</output>;
};
const ConfigHoC = withConfig(({ config: { hoc } }) => <h1>{hoc}</h1>);
const ConfigHook = () => {
const config = useConfig();
return <h1>{config.hook}</h1>;
};
const RichText = () => (
<>
<Text text="imported" />
<br />
<BoldText subject="text" />
</>
);
export default render(
<>
<Helmet>
<link rel="icon" href="data:;base64,iVBORw0KGgo=" />
</Helmet>
<div>
<Link to="/two">Link to two</Link>
<> </>
<Link to="/images">Link to images</Link>
<> </>
<Link to="/import">Link to import</Link>
<Switch>
<Route path="/" exact render={() => <h1>home</h1>} />
<Route path="/two" exact render={() => <h1>two</h1>} />
<Route path="/status" exact render={() => <Status code={418} />} />
<Route path="/redirect" exact render={() => <Redirect to="/two" />} />
<Route
path="/header"
exact
render={() => <Header name="X-Foo" value="Bar" />}
/>
<Route path="/flow" exact render={() => <FlowText text="flow" />} />
<Route path="/import" exact render={RichText} />
<Route path="/server-data-hoc" exact component={ServerDataHoC} />
<Route path="/server-data-hook" exact component={ServerDataHook} />
<Route path="/config-hoc" exact component={ConfigHoC} />
<Route path="/config-hook" exact component={ConfigHook} />
<Route path="/images" exact component={Images} />
<Miss />
</Switch>
</div>
</>
);