forked from RubyLouvre/anu
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
executable file
·69 lines (57 loc) · 1.59 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<!--
<script src="https://cdn.bootcss.com/react/16.9.0/umd/react.development.js"></script>
<script src="https://cdn.bootcss.com/react-dom/16.9.0/umd/react-dom.development.js" ></script>
-->
<script src="./dist/React.js"></script>
<script type='text/javascript' src="./lib/babel.js"></script>
</head>
<body>
<div id='root' class="root">
</div>
<script type='text/babel'>
var { lazy, Suspense } = React;
var OtherComponent = lazy(() => {
return new Promise(resolve =>
setTimeout(
() =>
resolve({
default: function render(props) {
//export default
return <div>Hello,{props.name}</div>;
}
}),
3000
)
);
});
var valueRef = React.createRef()
class App extends React.Component {
constructor(props){
super(props)
this.state = {
name: "ruby"
}
}
updateName(){
var name = valueRef.current.value;
this.setState({name})
}
render() {
return (
<div>
<p><input ref={valueRef} onChange={this.updateName.bind(this)} value={this.state.name} />{new Date-0}</p>
<Suspense fallback={<div>loading...</div>}>
<OtherComponent name={this.state.name} />
</Suspense>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById("root"));
</script>
</html>