forked from RubyLouvre/anu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index4.html
72 lines (58 loc) · 1.47 KB
/
index4.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
70
71
72
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<!--
<script src="https://cdn.bootcss.com/react/16.7.0-alpha.2/umd/react.development.js"></script>
<script src="https://cdn.bootcss.com/react-dom/16.7.0-alpha.2/umd/react-dom.development.js"></script>
-->
<script src="./dist/React.js"></script>
<script src="./lib/ReactPropTypes.js"></script>
<script type='text/javascript' src="./lib/babel.js"></script>
</head>
<body>
<div id='root' class="root">
</div>
<script type='text/babel'>
var container = document.getElementById('root');
var Theme = React.createContext("xxx")
var useContext = React.useContext
class A extends React.Component{
state = {
time: 19860219
}
onClick(){
this.setState({
time: new Date - 0
})
}
render(){
console.log('a render')
return <div>
<Theme.Provider value={this.state.time}>
<B />
<button type="button" onClick={
this.onClick.bind(this)
}> change </button>
</Theme.Provider>
</div>
}
}
class B extends React.Component{
shouldComponentUpdate(a, b){
return false
}
render(){
console.log('b render')
return <div><C /></div>
}
}
function C(){
var context = useContext(Theme)
console.log('c render')
return <strong>{context}</strong>
}
ReactDOM.render(<A />, container)
</script>
</html>