Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetcher is sometimes ignored and it uses the default fetch #26

Closed
rauchg opened this issue Nov 21, 2021 · 1 comment
Closed

fetcher is sometimes ignored and it uses the default fetch #26

rauchg opened this issue Nov 21, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@rauchg
Copy link

rauchg commented Nov 21, 2021

I ran into a scenario where passing a custom fetcher to useSWR was still creating fetch calls.

I had to work around it as follows unfortunately:

  const swr = createSWR({ fetcher: readUser });
  const { data: user, revalidate } = swr.useSWR("usertest", {
    dedupingInterval: 0,
    revalidateOnFocus: false,
  });

I was noticing that if I passed fetcher to useSWR instead, I'd see XHR to /usertest even though my fetcher doesn't use XHR at all.

@ConsoleTVs ConsoleTVs self-assigned this Nov 21, 2021
@ConsoleTVs ConsoleTVs added the bug Something isn't working label Nov 21, 2021
@ConsoleTVs
Copy link
Owner

That shall be fixed! The fetcher from the initial call will be respected if you revalidate or mutate from the given result func.

const { data: user, revalidate } = useSWR('...', { fetcher })

revalidate() // Should now respect fetcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants