0

I'm dispatching a thunk action that I expect to be rejected, but it's fulfilled instead...

Edit keen-darwin-i9r53l

  • why it should go to faliur state. you are doing nothing in catch block just thrown an error but in catch block. try something buggy to test this. – Wasif Ali Dec 14 '22 at 13:55

1 Answers1

1

You are not returning anything from the thunk, therefore the thunk is considered as fulfilled.

You should return rejectWithValue(e.message) in your catch block.

} catch (e) {
  errorMessage = `Log from catch block: ${e.message}`;
  return rejectWithValue(e.message);
}
Fer Toasted
  • 1,274
  • 1
  • 11
  • 27