swr icon indicating copy to clipboard operation
swr copied to clipboard

Type error when fallback option with undefined.

Open taku-hatano opened this issue 3 months ago • 0 comments

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.

taku-hatano avatar Mar 15 '24 02:03 taku-hatano