React.children.only 期望接收单个反应元素子导航器 [英] React.children.only expected to receive a single react element child Navigator
问题描述
我尝试了太多主题帮助,但这并不能帮助我解决此错误,也许是因为我是 react-native 的新手.
这是出错的代码.
render() {返回 (<提供者商店={商店}><导航器initialRoute={{ 名称:'唤醒' }}configureScene={(route, routeStack) =>Navigator.SceneConfigs.FloatFromBottom}renderScene={RouteMapper}/><标签/></提供者>);}
React.children.only 期望接收单个反应元素孩子"我在运行它时收到此错误.请帮忙.我知道还有很多其他类似的主题发布,但没有一个为我的问题提供适当的解决方案.
react-redux <Provider/>
组件期望其子 prop 是单个 ReactElement,即您的根组件应用.这可能是这个错误的来源.
道具
- store(Redux 商店):应用程序中的单个 Redux 商店.
- children (ReactElement) 组件层次结构的根.
示例
ReactDOM.render(<提供者商店={商店}><div><MyRootComponent/><其他组件1/><其他组件2/>//{...} 只要你把组件放在一个全局组件中//- 这里是 div - React 认为你只有一个孩子.那个.
</提供者>,根);
来源:https://github.com/reactjs/react-redux/blob/master/docs/api.md#provider-store
I tried too many topic helps but that doesn't help me to fix this error, maybe cuz i'm newbie to react-native.
here is the code which gives error.
render() {
return (
<Provider store={store}>
<Navigator
initialRoute={{ name: 'Wake' }}
configureScene={(route, routeStack) => Navigator.SceneConfigs.FloatFromBottom}
renderScene={RouteMapper}
/>
<Tabs />
</Provider>
);
}
"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.
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.
Props
- store (Redux Store): The single Redux store in your application.
- children (ReactElement) The root of your component hierarchy.
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
这篇关于React.children.only 期望接收单个反应元素子导航器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!