您能帮忙解决为什么我的容器没有将调度支柱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'.