swr-site icon indicating copy to clipboard operation
swr-site copied to clipboard

Feedback for “API Options – SWR”

Open cjstewart88 opened this issue 3 years ago • 0 comments

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:

Screen Shot 2022-12-06 at 10 14 35 AM

cjstewart88 avatar Dec 06 '22 15:12 cjstewart88