React-redux没有将mapDispatchToProps设置为props

时间:2016-10-15 23:42:43

标签: reactjs redux react-redux

您能帮忙解决为什么我的容器没有将调度支柱saveInfo转移到组件中吗?

我的容器:

import { connect } from 'react-redux'
import AddCarWashForm from './../components/carwash/subComponents/AddCarWashForm.jsx'
import {addInfo} from './../actions'

const mapDispatchToProps = (dispatch) => {
return {
    saveInfo: (info) => {
        dispatch(addInfo(info))
    }
}
}

const AddCarWashFormContainer = connect(
    null,
    mapDispatchToProps
)(AddCarWashForm)

export default AddCarWashFormContainer

这是AddCarWashForm.jsx

的一部分
export default class AddCarWashForm extends React.Component{

static contextTypes = {
    saveInfo: React.PropTypes.func.isRequired
};

当我执行此代码时,我会在控制台中看到:Warning: Failed context type: Required context 'saveInfo' was not specified in 'AddCarWashForm'.

0 个答案:

没有答案