我尝试了太多主题帮助,但这并不能帮助我修复这个错误,也许是因为我是 react-native 的新手。
这是给出错误的代码。
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” 我在运行时收到此错误。请帮忙。 我知道有很多其他类似的主题发布,但没有一个能为我的问题提供适当的解决方案。
最佳答案
react-redux <Provider />
component 期望它的子 prop 是一个单一的 ReactElement,你的应用程序的根组件。这可能是此错误的来源。
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 );
来源:https://github.com/reactjs/react-redux/blob/master/docs/api.md#provider-store
关于javascript - React.children.only 期望接收单个 react 元素子 Navigator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43300897/