-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.jsx
42 lines (37 loc) · 1000 Bytes
/
main.jsx
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
import './style.css'
import App from './App.jsx'
import { ReactDom } from './src/react-dom'
import { React } from './src/react/index'
import {ReactComponent} from './src/react/classComponent'
class Com extends ReactComponent {
constructor(){
super()
this.state = {count:10}
}
render(){
console.log('render')
return (
<div >
<Com2/>
<button onClick={() => {this.setState({count:++this.state.count})}}>setState</button>
<button onClick={() => console.log(this.state)}>showState</button>
<h1>count:{this.state.count}</h1>
</div>
)
}
}
class Com2 extends ReactComponent {
render(){
console.log('com2 rerender')
return <div>
<h1>com2</h1>
</div>
}
}
let a = new Com()
console.log(a.render())
let ele = <div>
<Com/>
</div>
let rootDom = document.getElementById('app')
ReactDom.render(ele,rootDom)