forked from RubyLouvre/anu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex5.html
97 lines (84 loc) · 2.66 KB
/
index5.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<!-- <script type='text/javascript' src="./lib/shallowCompare.js"></script>-->
<script type='text/javascript' src="./dist/React.js"></script>
<!-- <script type='text/javascript' src="./lib/ReactTestUtils.js"></script>-->
<!--<script type='text/javascript' src="./test/react.js"></script>
<script type='text/javascript' src="./test/react-dom.js"></script>-->
<!--<script type='text/javascript' src="./test/react-lite.js"></script>-->
<script type='text/javascript' src="./lib/babel.js"></script>
</head>
<body>
<div>开发者工具</div>
<pre>
</pre>
<div id='example'></div>
<script type='text/babel'>
var container = document.getElementById("example")
var div = container
// var PropTypes = React.PropTypes
if(!window.ReactDOM){
window.ReactDOM = window.React
var PropTypes = React.PropTypes
}
var expect = function(a) {
return {
toBe: function(b) {
console.log(a, b, a === b)
}
}
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
flag: 1
};
}
componentDidMount(props){
console.log("App did mount")
}
componentWillUpdate(props){
console.log("App will update")
}
componentDidUpdate(props){
console.log("App did update")
}
render() {
return (<div>{this.props.children}</div>);
}
}
class Child extends React.Component {
constructor(props) {
super(props);
this.state = {
text: props.text
};
}
render(){
return <span className={this.state.text}>{this.state.text}</span>
}
componentDidMount(props){
console.log("Child did mount")
}
componentWillReceiveProps(props){
console.log("Child ",this.props.text, "will receive")
this.setState({
text: props.text
})
}
componentWillUpdate(props){
console.log("Child ",this.props.text, "will update")
}
componentDidUpdate(props){
console.log("Child ",this.props.text, "did update")
}
}
var s = ReactDOM.render(<App><Child key="a" text="111" /><Child key="b" text="222" /></App>, div);
ReactDOM.render(<App><Child key="a" text="333" /><Child key="b" text="444" /></App>, div);
</script>
</body>
</html>