React-Redux-Thunk传递此。道具方法在行动中创建

React-Redux-Thunk传递此。道具方法在行动中创建,redux,react-redux,react-thunk,Redux,React Redux,React Thunk,我正在使用react with react stepzilla with Redux,Redux thunk问题是我想在action creator中使用jumpToState(n)方法。但我无法在redux action creator文件中访问此方法 动作文件 export const checkUser = (username) => { return (dispatch,getState)=>{ wApi({user:username}).then(res

我正在使用react with react stepzilla with Redux,Redux thunk问题是我想在action creator中使用jumpToState(n)方法。但我无法在redux action creator文件中访问此方法

动作文件

export const checkUser = (username) => {
    return (dispatch,getState)=>{
      wApi({user:username}).then(response => {
           dispatch({
              type: ActionTypes.CHECK_USER_NAME,
              payload:response
           })
           e.jumpToStep(1);//Here it is Stepzilla Method 
        }).catch(err => {})

      }
  }
getState()方法只提供我在reducer中声明的状态值。 console.log(getState)

减速器锉

const defaultState={
    userdetail:{
       username:""
       usertype:""
       isactive:""
    }
}
const reducer =(state=defaultState,action)=>{
    switch (action.type) {
        case ActionTypes.CHECK_USER_NAME :
          {
            return {
              ...state,
              userdetail:action.payload,
            }
          }
        default:
          return state
      }
}
export default reducer;
CheckUserName.js文件代码

componentWillMount() {
        this.props.checkUser("USER1001")
        //console.log(this.props)
        //{Here in console Output i can see "jumpToState"  method in this.props}
        //this.props.jumpToStep(1);
      }
通过将整个this.props传递给action creator方法,我找到了解决方案

this.props.checkUser("USER1001",this.props)

我想问有没有其他方法可以达到这个目的。从react stepzilla的文档中,我不熟悉react

stepzilla将一个名为
jumpToStep
的实用方法作为道具注入所有react step组件中

因为这是道具中的正常功能,所以可以将其作为参数传递给动作创建者并在那里使用。不需要传递整个
this.props

this.props.checkUser(“USER1001”,this.props.jumpToStep)
export const checkUser=(用户名,jumpToStep)=>{
返回(调度,获取状态)=>{
wApi({user:username})。然后(响应=>{
派遣({
类型:ActionTypes.CHECK\u USER\u NAME,
有效载荷:响应
})
jumpToStep(1);//这里是Stepzilla方法
}).catch(err=>{})
}
}

来自react stepzilla的文档:

stepzilla将一个名为
jumpToStep
的实用方法作为道具注入所有react step组件中

因为这是道具中的正常功能,所以可以将其作为参数传递给动作创建者并在那里使用。不需要传递整个
this.props

this.props.checkUser(“USER1001”,this.props.jumpToStep)
export const checkUser=(用户名,jumpToStep)=>{
返回(调度,获取状态)=>{
wApi({user:username})。然后(响应=>{
派遣({
类型:ActionTypes.CHECK\u USER\u NAME,
有效载荷:响应
})
jumpToStep(1);//这里是Stepzilla方法
}).catch(err=>{})
}
}
this.props.checkUser("USER1001",this.props)