Eugene Podoliako Eugene Podoliako - 1 month ago 15
React JSX Question

React-redux doesn't set mapDispatchToProps into props

Can you help to undestand why my container doesn't transfer dispatch prop

saveInfo
into component?

My container:

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


Here is part of AddCarWashForm.jsx

export default class AddCarWashForm extends React.Component{

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


And when I execute this code, I see in console:
Warning: Failed context type: Required context 'saveInfo' was not specified in 'AddCarWashForm'.

Answer

You're mapping to props, not to context. Define it as a propType instead and it'll work as you expect it.

Comments