Closed
Description
openedon Jun 9, 2023
Imo these 2 statements are wrong and encourage developers using old-style Promise syntax instead async/await
.
If you need to access the error or success payload immediately after a mutation, you can chain .unwrap().
https://redux-toolkit.js.org/rtk-query/usage/error-handling#error-display-examples
This can be useful if you wish to determine whether the mutation succeeds/fails inline at the call-site.
https://redux-toolkit.js.org/rtk-query/usage/mutations#frequently-used-mutation-hook-return-values
If i need to access payload immediately after a mutation I will use
const [trigger] = useMutation();
...
...
const result = await trigger(...);
// result is "the error or success payload retrieved immediately after a mutation" and can be used "to determine whether the mutation succeeds/fails inline at the call-site"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels