2016-10-15 2 views
0

왜 내 컨테이너가 saveInfo 파견 물품을 구성 요소로 전송하지 않는 지 알려주시겠습니까?React-redux가 mapDispatchToProps를 소품으로 설정하지 않았습니다

내 컨테이너 :

여기
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'.

답변

1

을 소품 (문맥에 맞지 않는). 대신 propType으로 정의하면 예상대로 작동합니다.

관련 문제