ReactNative使用TabBar报错react.children.only expected to receive a single react element child
来源:互联网 发布:笨方法学python在线 编辑:程序博客网 时间:2024/06/07 01:38
ReactNative使用TabBar报错react.children.only expected to receive a single react element child
实例代码:
<TabBarIOS.Item title="首页" icon={require('./img/动态副本.png')} selected={this.state.selectedTab === '首页'} onPress={() =>{ this.setState({ selectedTab:'首页', }); }}> </TabBarIOS.Item>//一运行就报错react.children.only expected to receive a single react element child
解决办法:
React Native 中无论是 TabBarIOS.Item 还是 TabBar.Item 必须有且只有一个组件,说白了就是需要有子组件的存在,并且只存在一个子组件。
<TabBarIOS.Item title="首页" icon={require('./img/动态副本.png')} selected={this.state.selectedTab === '首页'} onPress={() =>{ this.setState({ selectedTab:'首页', }); }}> <View > <Text>首页</Text> </View> </TabBarIOS.Item>
1 0
- ReactNative使用TabBar报错react.children.only expected to receive a single react element child
- reactNative react.children.only expected to receive a single react element child.问题
- ReactNative-底部TabBar react-native-tab-navigator
- Reactnative 使用React TabNavigator
- react-native 踩坑之onlychild must br passed a children with exaxtly one child
- 解决:react native使用TabNavigator报错 PropTypes has been moved to a separate package...
- React.Children
- ReactNative警告:bind(): React component methods may only be bound to the component instance
- react-native---配置reactnative报红,run-Android时候报错unable to load script from assets 'index.android.bundl
- React报错Warning:setState(...):Can only update a mounted or mounting component...
- react-native报错-Unable to resolve module ‘react’
- react-native中debug报错信息:Each child in an array or iterator should have a unique "key" prop.
- react-native Element type is invalid: expected a string (for built-in components) or a class/functio
- React-Native项目中使用TabBar
- React-Native项目中使用TabBar
- IE8报错:Unable to modify the parent container element before the child element is closed
- react-bits:Children类型
- react-bits:Children types
- 四分位算法
- 自定义时间工具类
- c++排序函数sort(),qsort()的用法
- oracle 用户权限批量授予
- 仿淘宝搜索框 -- 输入内容隐藏默认文本
- ReactNative使用TabBar报错react.children.only expected to receive a single react element child
- H264格式
- Redis学习---初级篇,安装与配置
- Android Logcat
- 异或运算xor
- struts2如何从一个Action转到另外一个Action
- jstat命令详解
- 简捷的python
- JS构造函数设计模式