swr icon indicating copy to clipboard operation
swr copied to clipboard

useSWRMutation - to have both `trigger` and `triggerAsync`

Open anirudh1713 opened this issue 2 years ago • 0 comments

CONTEXT

Continuing the discussion from #1973

Currently useSWRMutation returns a trigger method which returns Promise<Data> which may cause confusion like here. though it should be clear to developers if they just take a look at the types however that is not the only reason for this request, developers might just want to use the onError callback and don't want to bother catching errors manually.

Proposal

It may be better to return both trigger and triggerAsync, where trigger will return void and triggerAsync will return Promise<Data> (or vice versa) :thinking:

This is similar to #1951

anirudh1713 avatar May 27 '22 14:05 anirudh1713