我有一个组件可以触发一些依赖异步 API 请求的方法。我使用 componentWillmount 检查一些道具。如果这个道具是true
我触发一些功能,否则为假。但问题是,第一次 prop 是undefined
,只有过一段时间才会变成false
or true
。如何检查它并等待请求解决?
componentWillMount = () => {
this.props.init(parseInt(this.props.tagId, 16), this.props.accessToken);
if (!this.props.notFound && !this.props.person) this.props.onFreeTag();
};