Skip to content

Is RTK opinionated about standalone actions (i.e. actions declared outside of a slice)? #4703

Answered by markerikson
PeterTYLiu asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PeterTYLiu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants