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

Type error when fallback option with undefined. #2912

Closed
taku-hatano opened this issue Mar 15, 2024 · 0 comments · Fixed by #2913
Closed

Type error when fallback option with undefined. #2912

taku-hatano opened this issue Mar 15, 2024 · 0 comments · Fixed by #2913

Comments

@taku-hatano
Copy link
Contributor

Bug report

Description / Observed Behavior

An error will occur if the fallback option for useSWR is undefined.

const { data, error } = useSWR("/api/hello", {
  fallback: undefined
});

fallback option can be specified as undefined in the type definition.  
The above code causes the following error.

TypeError: Cannot read properties of undefined (reading '/api/hello')

Expected Behavior

I think fallback option should check if it is undefined.
(For example, here)

Repro Steps / Code Example

CodeSandbox

Additional Context

SWR version. 2.2.5
Add any other context about the problem here.

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.

1 participant