1 回答

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊
那這說(shuō)明你的connect用的不對(duì),你這個(gè)createSelector不太清楚你這個(gè)是自己封裝的還是第三方插件,單connect這個(gè)插件來(lái)說(shuō),它接受的參數(shù)一共有四個(gè),分別是 mapStateToProps , mapDispatchToProps, mergeProps 和 options。其中一般用到前兩個(gè)差不多了。
mapStateToProps
將 store 中的數(shù)據(jù)作為 props 綁定到組件上。
const mapStateToProps = (state) => {
return {
count: state.count
}
}
mapDispatchToProps
將 action 作為props 綁定到組件上
const mapDispatchToProps = (dispatch, ownProps) => {
return {
increase: (...args) => dispatch(actions.increase(...args)),
decrease: (...args) => dispatch(actions.decrease(...args))
}
}
你對(duì)一下看你是不是傳的有問(wèn)題
添加回答
舉報(bào)