为什么 console.log 在构造函数和渲染函数中打印两次值?
这里是:
class App extends React.Component {
constructor(props) {
console.log('Constructor');
super(props)
this.state = {
counter: 0
}
}
render() {
console.log('render');
return (
<div style={{ fontSize: '45px', fontWeight: 'bold' }}>
Counter: {this.state.counter}
</div>
)
}
}