映射调度道具并将它们连接起来不正常

时间:2018-01-01 11:46:59

标签: typescript react-redux dispatch react-props

我有以下课程:

type globalProbs = {createActivity:(period:Models.Period)=>void}
type props = { period: Models.Period, curriculum: Models.Curriculum };

type allProps = globalProbs & props;
export class PeriodEditCell extends React.Component<allProps, {}> {
我使用connect导出的

const mapDispatchToProps = (dispatch: Dispatch<globalProbs>): globalProbs => {
    return ({
        createActivity: Firebase.actionCreators.createActivity
    })
  }

export default connect(mapDispatchToProps)(PeriodEditCell);

在firebase的动作创建者中我有这个:

export const actionCreators = {
     createActivity: (period: Models.Period): AppThunkAction<any> => async (dispatch, getState) =>{
//....
      }
}

我的AppThunkAction界面:

export interface AppThunkAction<TAction> {
  (dispatch: (action: TAction) => void, getState: () => RootState): void;
}

我的问题是,当我在PeriodEditCell组件中调用this.props.createActivity(blah)时,函数似乎会进入createActivity,但不会进入正文,因此AppThunkAction出现问题

我不知道自己做错了什么,因为我过去曾做过类似的事情并且有效...

0 个答案:

没有答案