我想在mapStateToProps
內使用三元語句,但它似乎並沒有更新狀態,我仍然跑mapStateToProps must return a plain object. Instead received undefined.
此語法不正確?mapStateToProps必須返回一個普通對象。相反收到undefined
const mapStateToProps = state => {
console.log("current state is:" + JSON.stringify(state.model));
state.model.selectedPerson ?
{
selectedCourse: state.model.selectedPerson.selectedCourse,
startDate: state.model.selectedPerson.startDate,
courseType: state.model.selectedPerson.courseType,
} :
{
selectedCourse: [],
startDate: '',
courseType: '',
};
};
const reducers = Object.assign({}, { model: courseReducers });
export { reducers };
export default connect(mapStateToProps, mapDispatchToProps)
(AddCourseDialog);
我想在自定義模式中使用一個窗體,上面的容器包含在其他2個父容器中。我還沒有探索使用redux形式呢。
我沒有看到任何以上,但狀態不會得到更新控制檯上的錯誤。我不認爲減速器在調度過程中被調用。有沒有辦法在reducer中放入console.log語句? – linuxNoob