[英]React-Redux error Invalid prop `children` of type `object` supplied to `Provider`
I am very much stumbling my way through learning how Redux works. 通过学习Redux的工作原理,我非常绊脚石。 I'm currently getting the following errors:
我目前遇到以下错误:
Warning: Failed propType: Invalid prop `children` of type `object` supplied to `Provider`, expected `function`
Uncaught TypeError: children is not a function
My code is below -- is anyone able to spot why I'm getting this error? 我的代码如下-有人能发现我为什么收到此错误吗?
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { createStore, combineReducers } from 'redux';
import { Provider, connect } from 'react-redux';
import * as reducers from '../reducers/index';
import SassMeter from '../components/SassMeter';
import * as SassActions from '../actions/SassActions';
import _ from 'lodash'
const reducer = combineReducers(reducers);
const store = createStore(reducer);
ReactDOM.render(
<Provider store={store}>
<SassMeter />
</Provider>,
document.getElementById('root')
)
From what I understand, it's complaining that I'm passing an invalid prop to Provider, but all the examples I've seen follow the pattern I've followed there -- create the store using createStore()
, then pass it in as props to the Provider, which wraps your root element. 据我了解,这是在抱怨我向Provider传递了无效的prop,但是我看到的所有示例都遵循我在此处遵循的模式-使用
createStore()
创建商店,然后将其作为prop传入提供者,后者包装您的根元素。 I feel like maybe I'm missing something to do with connect
but I'm not sure what. 我觉得也许我错过了一些与
connect
事情,但我不确定该怎么做。
All help much appreciated! 所有帮助非常感谢!
You should most likely upgrade your version of react-redux
and/or react
. 您应该最有可能升级您的
react-redux
和/或react
。
In React < 0.14 and react-redux < 1.0.0, the Provider component only accepted a function as the children
prop. 在React <0.14和react-redux <1.0.0中,Provider组件仅接受一个函数作为
children
道具。 This was a workaround to owner-based context propagation, which was deprecated in favor of parent-based context propagation in React 0.14. 这是基于所有者的上下文传播的解决方法,不建议使用此方法,而在React 0.14中推荐使用基于父级的上下文传播。 See the corresponding doc on the react-redux 1.0.0 README.
请参阅react-redux 1.0.0自述文件上的相应文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.