加与不加props的区别究竟在哪里呢?
以下来自stackoverflow的解释:
What’s the difference between “super()” and “super(props)” in React when using es6 classes?
不加props
1 | constructor(props) { |
加props
1
2
3
4constructor(props) {
super(props);
console.log(this.props) //props will get logged.
}