React.children.only 期望接收单个 React 元素子导航器

2023-11-27

我尝试了太多的主题帮助,但这并不能帮助我解决这个错误,也许因为我是反应原生的新手。

这是给出错误的代码。

render() {
  return (

  <Provider store={store}>

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

    <Tabs />



  </Provider>


 );
}

“React.children.only 期望接收单个反应元素子元素”,当我运行它时,我收到此错误。请帮忙。 我知道有很多其他主题发布了类似的内容,但没有一个主题能够正确解决我的问题。


反应还原<Provider />组件期望其子属性是单个 ReactElement,即应用程序的根组件。这可能就是这个错误的来源。

Props

  • store (Redux Store):应用程序中的单个 Redux 存储。
  • Children (ReactElement) 组件层次结构的根。

Example

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
);

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

React.children.only 期望接收单个 React 元素子导航器 的相关文章

随机推荐