swr
swr copied to clipboard
useSWRMutation - to have both `trigger` and `triggerAsync`
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