javascript - Provider 中的无效 Prop child

标签 javascript reactjs redux react-redux

过去几周我一直在学习 React。
首先使用普通 React 开发了一个简单的 Chat,现在我开始将 Redux 集成到我的应用程序中。

我添加了一个简单的 Action、一个匹配的 Reducer(以及一个根 Reducer)和一个 Store。 然后我到达了需要使用 react-redux 库中的 Provider 的部分:

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import ConfigureStore from './Store/ConfigureStore';
import Routes from './Routes';

const store = ConfigureStore();
ReactDOM.render(
    <Provider store={store}>
        <Router history={browserHistory}
            routes={Routes} />,
    </Provider>,
    document.getElementById('root')
);

应用程序编译正常,但我在控制台中收到以下错误:

Warning: Failed prop type: Invalid prop children of type array supplied to Provider, expected a single ReactElement. in Provider

Uncaught Invariant Violation: React.Children.only expected to receive a single React element child.

我正在使用 React Create App 作为入门工具包。

可以找到完整代码here .

最佳答案

你有一个 ,<Router history={browserHistory} routes={Routes} /> 之后

尝试删除它?

关于javascript - Provider 中的无效 Prop child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40181363/

相关文章:

javascript - React JS 待办事项列表应用 |获取值并推送到状态

javascript - 在 React 和 Redux 中更新 props 而不留下函数

javascript - computeDistanceBetween 似乎计算不正确

javascript - 如何将查询的数据(通过帖子)放在我的 jquery 图表上?

javascript - 将状态值作为 props 传递给另一个组件 es6

javascript - 从 Redux 中导出值(value),使其全局化

reactjs - React Redux 状态在页面刷新时丢失

javascript - Safari 上的 createImageBitmap 替代方案

javascript - Jquery javascript : have a filtering list(works), 需要帮助在没有匹配项时保持所有 LI 可见

javascript - 有没有办法可以在链接标记中链接到本地​​常量文件