Replies: 1 comment
-
your user-land implementation also violates the rules of hooks. If the passed-in I don’t think this is worth pursuing because the prime use-case for Also, I don’t usually see the problem with multiple |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When working with multiple mutations in the same component, it is very common to write repetitive useMutation calls:
This is verbose, but more importantly, it often tempts developers to try abstraction patterns that violate the Rules of Hooks (e.g. calling useMutation inside loops or conditionals).
Because of this, I believe library-level support for batching mutations—similar to useQueries—would be safer and more ergonomic than encouraging ad-hoc abstractions at the application level.
Desired API
What I want to write is something like this:
This mirrors the mental model of useQueries, but for mutations.
Current Implementation (Userland Prototype)
Below is a userland implementation I experimented with.
It ensures:
Discussion Points
English is not my native language, so please excuse any awkward phrasing :)
I would love feedback from the maintainers and the community.
Beta Was this translation helpful? Give feedback.
All reactions