【发布时间】:2017-08-30 12:41:55
【问题描述】:
EDIT:
我添加了React.Element<*>作为返回类型,并返回<View />而不是null,但仍然有同样的错误。
而我的流程版本是0.53.1
render() {
return (
<View style={{ flex: 1 }} >
<TabHeader title={strings.tabBarLabelRecommend} />
{this._renderVideoCategory()}
</View>
);
}
上面是我的渲染方法,_renderVideoCategory 是:
_renderVideoCategory = (): React.Element<*> => {
if (!this.props.recommendVideos.length) {
return <View />;
}
this.tabWidth = C.SCREEN_WIDTH / this.props.recommendVideos.count;
return (
<TabViewAnimated style={{ flex: 1 }}
navigationState={this.state}
renderScene={this._renderScene}
renderHeader={this._renderHeader}
renderPager={this._renderPager}
onRequestChangeTab={this._handleChangeTab}
/>
);
};
但是流程显示错误:(第150行是{this._renderVideoCategory()})
Error:(150, 10) Flow: exact type: object type. This type is incompatible with union: undefined | null | boolean | number | string | type application of type React$Element | type application of identifier Iterable
【问题讨论】:
-
这与您的答案无关。现在我正在学习 React-Native,但我没有找到任何好的网站,如果你知道任何好的网站并且都在一个地方,你能分享一下吗?
-
您能准确说明代码中第 150 行的位置吗?
标签: reactjs react-native flowtype