Closed rauchg closed 2 years ago
(Great work on sswr btw! Enjoying it 🤗 )
@rauchg I quickly checked the types for the fetcher function:
type SWRFetcher<D = any> = (...props: any[]) => Promise<D>;
I'm curious how it allowed you to use a fetcher function that didn't return a Promise. I will cover this use case, but may I know if you were using Typescript and/or vscode?
For local storage cases like
localStorage
, I ran into an obscure error where it was complaining that the return value didn't have.catch
. I fixed by turning my sync fetcher into anasync
function.Furthermore, it might be worth considering accepting the fetcher as the second param, since that's how SWR also works.