swr-site
swr-site copied to clipboard
Feedback for “API Options – SWR”
We have an endpoint we'd like to poll for changes. This setup works:
const { data, mutate } = useSWR<Data>(
endpoint,
{
refreshInterval: 3000,
}
)
This works too:
const { data, mutate } = useSWR<Data>(
endpoint,
null,
{
refreshInterval: 3000,
}
)
The confusion for us is when we first read the docs, this is how we interpreted it:
const { data, mutate } = useSWR<Data>(
endpoint,
undefined, // we thought we could pass in undefined and our default fetcher would be used
{
refreshInterval: 3000,
}
)
However, this way ignore the config options.
I think adding the notice below to the "API Options" page would make it obvious that the fetcher can be omitted:
