简体   繁体   English

React-Redux错误提供给提供者的对象类型为对象的无效子属性prop

[英]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.

相关问题 警告:道具类型失败:提供给“提供者”的对象类型为“对象”的道具儿童无效,需要一个ReactElement - Warning: Failed prop type: Invalid prop `children` of type `object` supplied to `Provider`, expected a single ReactElement React Native错误失败的道具类型:提供给`Overlay`的`array`类型的无效道具`children`, - React Native error Failed prop type: Invalid prop `children` of type `array` supplied to `Overlay`, 反应错误'Failed propType:提供给`Provider`的无效道具`children`,期望一个ReactElement' - React error 'Failed propType: Invalid prop `children` supplied to `Provider`, expected a single ReactElement' 提供的React Redux无效道具 - React Redux Invalid Prop supplied 提供者react-redux中的错误 - Error in Provider react-redux 警告:失败的道具类型:提供给“路由”的“对象”类型的无效道具“组件”,预期的“函数”使用 react-router-dom 错误 - Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function` Error using react-router-dom 获取错误:警告:道具类型失败:提供给“Form”的道具“children”无效,应为 ReactNode - GETTING ERROR : Warning: Failed prop type: Invalid prop `children` supplied to `Form`, expected a ReactNode 道具类型失败:提供给“CSSTransition”的道具“children”无效 - Failed prop type: Invalid prop `children` supplied to `CSSTransition` react-redux 提供者的上下文实例属性是什么? - What is the context instance prop of react-redux provider? prop`store`如何在react-redux Provider中工作? - How does the prop `store` work in react-redux Provider?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM