Skip to content

fix: allow null fetcher to override global SWRConfig fetcher#4238

Open
Gdhanush-13 wants to merge 1 commit intovercel:mainfrom
Gdhanush-13:fix/null-fetcher-override
Open

fix: allow null fetcher to override global SWRConfig fetcher#4238
Gdhanush-13 wants to merge 1 commit intovercel:mainfrom
Gdhanush-13:fix/null-fetcher-override

Conversation

@Gdhanush-13
Copy link
Copy Markdown

Fixes #2888

useSWR('key', null) with a global SWRConfig fetcher still fires a request because fn || config.fetcher treats null as falsy.

Changed to fn !== undefined ? fn : config.fetcher || null so explicitly passing null is respected as an intentional override.

When fn is explicitly null, the || operator falls through to
config.fetcher. Use !== undefined check so null is respected
as an intentional override.

Fixes vercel#2888
@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Apr 5, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

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 this pull request may close these issues.

Type error when overriding global fetcher function with null

1 participant