【发布时间】:2019-10-26 20:38:18
【问题描述】:
我正在尝试在 render() 中使用异步函数:
async _check() {
const token = await AsyncStorage.getItem('myToken');
if(token !== null) {
this.props.navigation.navigate('My Screen', {token: token});
}
else {
return (
<View style={styles.content_container}>
...
</View>
);
}
}
render() {
return (
<View>
{ this._check() }
</View>
);
}
但我收到此错误:Invariant Violation: Invariant Violation: Objects are not valid as a React child (found: object with keys {_40, _65, _55, _72}). If you meant to render a collection of children, use an array instead.
谁能告诉我我的代码有什么问题?
【问题讨论】: