preserve swr mutate

This commit is contained in:
shamoon 2023-04-05 22:45:27 -07:00
parent 64b43871c6
commit 379d2e59f1

View File

@ -7,7 +7,7 @@ export default function useWidgetAPI(widget, ...options) {
if (options && options[1]?.refreshInterval) {
config.refreshInterval = options[1].refreshInterval;
}
const { data, error } = useSWR(formatProxyUrl(widget, ...options), config);
const { data, error, mutate } = useSWR(formatProxyUrl(widget, ...options), config);
// make the data error the top-level error
return { data, error: data?.error ?? error }
return { data, error: data?.error ?? error, mutate }
}