使用TabBarIOS.Item,报错如下:
react.children.only expected to receive a single react element child
代码如下:
<TabBarIOS.Item systemIcon="bookmarks"
selected={this.state.selectedItem === 'page-4'}
onPress={()=>this.setState({selectedItem:'page-4'})}>
</TabBarIOS.Item>
报错原因:
TabBarIOS.Item组件必须包含子元素,且子元素必须是一个组件
代码修正如下:
<TabBarIOS.Item systemIcon="bookmarks"
selected={this.state.selectedItem === 'page-4'}
onPress={()=>this.setState({selectedItem:'page-4'})}>
<View style={styles.pageStyle}>
<Text>Page-4</Text>
</View>
</TabBarIOS.Item>