-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (60 loc) · 1.52 KB
/
index.js
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
import React from "./react"
import ReactDom from "./react-dom"
const element = (
<div className='title' style={{color: '#58bc58 '}}>
hello <span>react</span>
</div>
)
// const Home = function () {
// return <div className='title' style={{color: '#58bc58 '}}>
// hello <span>react</span>
// </div>
// }
class Home extends React.Component {
constructor(props) {
super(props);
this.state = {
num : 1
}
}
componentWillMount() {
console.log('WillMount')
}
componentWillReceiveProps(props) {
console.log('props')
}
componentWillUpdate() {
console.log('update')
}
componentDidUpdate() {
console.log('diupdate')
}
componentDidMount() {
console.log('didmount')
for (let i = 0; i<10 ; i++) {
this.setState((prev) => {
console.log(prev.num)
return {
num: prev.num+1
}
})
}
}
handlerClick() {
console.log(666)
this.setState({
num: this.state.num + 1
})
}
render() {
return (
<div className='title' style={{color: '#58bc58 '}}>
hello <span>react</span>
{this.state.num}
<button onClick={this.handlerClick.bind(this)}>click</button>
</div>
);
}
}
// ReactDom.render('React', document.querySelector('#root'))
ReactDom.render(<Home/>, document.querySelector('#root'))