Is RTK opinionated about standalone actions (i.e. actions declared outside of a slice)? #4703
-
RTK gives us a straightforward way to declare actions via Should we avoid standalone actions and try to always create actions via |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We've generally found that (fake but accurate stat) 95% of actions are only ever handled by one slice. So, We also did work a while back to make it possible for slices to cross-import each other's actions without generally causing circular import errors. Given that, there should be relatively few times that you specifically need to use But, it's always your codebase, and you should feel free to do that if you feel it's appropriate. |
Beta Was this translation helpful? Give feedback.
We've generally found that (fake but accurate stat) 95% of actions are only ever handled by one slice. So,
createSlice
was designed to make that use case straightforward: write a case reducer, get the action creator generated for free.We also did work a while back to make it possible for slices to cross-import each other's actions without generally causing circular import errors.
Given that, there should be relatively few times that you specifically need to use
createAction
to define an action outside of a slice.But, it's always your codebase, and you should feel free to do that if you feel it's appropriate.