0

I'm trying to push these two variables current and duration to the redux store. And I'm getting this error. I'm new to this so can someone please tell me what am I doing wrong?

enter image description here

  const timeUpdateHandler = (e) => {
    const current = e.target.currentTime;
    const duration = e.target.duration;

    dispatch(timerUpdate(current, duration));
  };

This is the action creator in the store file:

export const timerUpdate = (current, duration) => async (dispatch) => {
  console.log(current);

  dispatch({
    type: PLAYER_TIMER_UPDATE,
    payload: {
      currentTime: current,
      duration: duration,
    },
  });
};
1

1 Answer 1

1

The problem is, your action creator does not return an object but a Promise<object>. This is because of the async keyword before your action creator.

The async keyword wraps the result in a promise. The code chunk you have posted does not have any async functionality so you can safely remove it.

On the other hand, if you do want async actions, try using redux-thunk library as suggested by HMR

Sign up to request clarification or add additional context in comments.

1 Comment

Hey, I added thunk and now it is working like how it should. That async was put there by mistake. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.