Async action triggered even if middleware doesn't call next(action) #1582
-
Hello, I'm moving a reactJS app from redux to redux toolkit. Here is my store
Here is one slice I created
And finally my super basic Middleware just to make my tests:
Now if I dispatch the action registerRetailer from the retailerRegistrationSlice, even if in the middleware it won't call next(action) my action is still triggered (and my API call is made). Thank you for putting me on the right direction. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
I'm not sure what you mean by "my action is still triggered and the API call is made". Can you clarify? Note that thunks are completely different than actions. An action is a plain object with a https://redux.js.org/usage/writing-logic-thunks So yes, if you dispatch a thunk, it will execute, and this middleware won't do anything to stop it. |
Beta Was this translation helpful? Give feedback.
I'm not sure what you mean by "my action is still triggered and the API call is made". Can you clarify?
Note that thunks are completely different than actions. An action is a plain object with a
type
field. A thunk is a function:https://redux.js.org/usage/writing-logic-thunks
So yes, if you dispatch a thunk, it will execute, and this middleware won't do anything to stop it.