React.children.only仅预期接收单个react元素子导航器 [英] React.children.only expected to receive a single react element child Navigator

查看:59
本文介绍了React.children.only仅预期接收单个react元素子导航器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了太多的主题帮助,但这并不能帮助我解决此错误,也许是因为我是本机响应的新​​手.

I tried too many topic helps but that doesn't help me to fix this error, maybe cuz i'm newbie to react-native.

这是给出错误的代码.

render() {
  return (

  <Provider store={store}>

    <Navigator
      initialRoute={{ name: 'Wake' }}
      configureScene={(route, routeStack) => Navigator.SceneConfigs.FloatFromBottom}
      renderScene={RouteMapper}
    />

    <Tabs />



  </Provider>


 );
}

"React.children.only预期会收到单个react元素子级",我在运行它时遇到此错误.请帮忙.iam知道还有很多其他类似的话题,但是没有一个能为我的问题提供适当的解决方案.

"React.children.only expected to receive a single react element child" i get this error when i run it. please help. iam aware that there are lot of other topics posted similar but none gives a proper solution to my problem.

推荐答案

react-redux < Provider/> 组件希望其子属性是单个ReactElement,即您的根组件应用.可能正是这个错误的来源.

The react-redux <Provider /> component expects its child prop to be a single ReactElement, the root component of your application. That is probably where this error is coming from.

道具

  • 商店(Redux商店):应用程序中的单个Redux商店.
  • children(ReactElement)组件层次结构的根.

示例

ReactDOM.render(
  <Provider store={store}>
    <div>
        <MyRootComponent/>
        <OtherComponent1/>
        <OtherComponent2/>
        // {...} as longer you let the component inside one global component 
        // - here the divs - React considers you have only one child. That it. 
    </div>
  </Provider>,
  rootEl
);

来源: https://github.com/reactjs/react-redux/blob/master/docs/api.md#provider-store

这篇关于React.children.only仅预期接收单个react元素子导航器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆