Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type field to action creators #155

Closed
chawes13 opened this issue Jun 29, 2023 · 0 comments · Fixed by #156
Closed

Add type field to action creators #155

chawes13 opened this issue Jun 29, 2023 · 0 comments · Fixed by #156
Assignees

Comments

@chawes13
Copy link
Contributor

chawes13 commented Jun 29, 2023

This will allow for better RTK support when defining apiActions in the extraReducers field.

The toString() override is getting removed in 2.0 in favor of referencing the type attribute.

Instead of having to write

extraReducers: (builder) => {
  builder.addCase(apiActions.fetchTodo.toString(), todoHandler)
}

we can add a type attribute and simply pass in the action creator function itself

extraReducers: (builder) => {
  builder.addCase(apiActions.fetchTodo, todoHandler)
}

Personally, I forgot to do this several times and it led to some pretty subtle bugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant