Skip to content Skip to sidebar Skip to footer

Promise Not Returning When Using MapDispatchToProps

Recently I've transitioned from using one optimistic action to adding two more to detect success/failure server responses. With the optimistic approach I was able to just pass in m

Solution 1:

The syntax of you mapDispatchToProps function seems to be incorrect. It must returns an object containing methods as properties.

try to write something like that :

function mapDispatchToProps(dispatch) {
  return {
    updatePost() {
      return dispatch(updatePost(id, props))
        .then(result => {
          if (result.payload.response && result.payload.response.status !== 200) {
           return dispatch(updatePostFailure(result.payload.response.data));
          }
          return dispatch(updatePostSuccess(result.payload.data));         
        });
    }
  }
}

Post a Comment for "Promise Not Returning When Using MapDispatchToProps"