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

When providing fetcher: null , middleware is defaulting it to undefined #2217

Closed
jquintozamora opened this issue Oct 31, 2022 · 1 comment · Fixed by #2240
Closed

When providing fetcher: null , middleware is defaulting it to undefined #2217

jquintozamora opened this issue Oct 31, 2022 · 1 comment · Fixed by #2240

Comments

@jquintozamora
Copy link

Bug report

We're building a custom middleware were we interact with fetcher.
We check if fetcher === null, but we receive fetcher as undefined inside middleware callback.

 const myCustomMiddleware = (useSwrNext) =>
  (key, fetcher, config) => {
    const extendedFetcher =  fetcher === null ? null : myFetcher
    ....

The issue is that fetcher comes undefined even if we set it as null in our useSWRImmutable("myKey", null, options)
Types doesn't allow us to define fetcher as undefined in useSWRInmutable.

Expected Behavior

Middleware returns fetcher as null when we set it null in useSWRInmutable

SWR version.
"swr": "^1.3.0"

@koba04
Copy link
Collaborator

koba04 commented Nov 12, 2022

@jquintozamora Thank you! I've created a PR to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants