score:1

you shouldn't expect updated state within the same function call. if you want to have new state, you should probably process it in the same action where you received it:

export const loadcourseinfo = (id:any) => async (dispatch:dispatch, getstate:any) => {
  ...
    const course = await apiservice.courses.getcourse(id);
    // use it right here
};

or you could use updated state on next render.


Related Query

More Query from same tag