1state在constructor方法里写
constructor(props) {
this.state = {
n: ...
}
}
2 写default props有两种方法
//1 在组件内部的使用static
...
static defaultProps = {
name: ...
}
//2 在组件外部
Hello.defaultProps = {
name: ...
}
1state在constructor方法里写
constructor(props) {
this.state = {
n: ...
}
}
2 写default props有两种方法
//1 在组件内部的使用static
...
static defaultProps = {
name: ...
}
//2 在组件外部
Hello.defaultProps = {
name: ...
}