clear all convos in progress, async code refactored in debugging warning

This commit is contained in:
Daniel Avila 2023-02-07 19:07:48 -05:00
parent 053368646d
commit 511ac948b4
10 changed files with 84 additions and 65 deletions

View file

@ -11,8 +11,11 @@ const postRequest = async (url, { arg }) => {
export const swr = (path) => useSWR(path, fetcher);
export default function manualSWR(path, type, successCallback) {
const options = {};
if (successCallback) {
options.onSuccess = successCallback;
}
const fetchFunction = type === 'get' ? fetcher : postRequest;
return useSWRMutation(path, fetchFunction, {
onSuccess: successCallback
});
return useSWRMutation(path, fetchFunction, options);
};