getDefaultProps在创建任何实例之前被调用,因此不能依赖
this.props。这是为了在所有者未通过默认道具的情况下获取默认道具。
另一种解决方案是使用,
getInitialState因为这将使您可以访问
this.props.user和
this.props.comment。

getDefaultProps在创建任何实例之前被调用,因此不能依赖
this.props。这是为了在所有者未通过默认道具的情况下获取默认道具。
另一种解决方案是使用,
getInitialState因为这将使您可以访问
this.props.user和
this.props.comment。