You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to #339. When the suspense option is enabled, SWR can not return any value to continue rendering, neither throwing any promise if it can't fetch. This includes 2 situations:
suspense: true and key is falsy.
suspense: true and fetcher is null.
In both cases SWR should throw an error.
The text was updated successfully, but these errors were encountered:
@shuding
How are you going to add the error?
The easiest way to add this is like the following.
if(suspense&&(!key||fetcher===null)){thrownewError("Either key or fetcher must be specified with suspense mode");}
But I think SWR hasn't had any errors like this yet and its bundle size is important. Those error messages cannot be minified and would increase the bundle size. Is it acceptable for SWR?
Or are you going to adopt a way to avoid increasing its bundle size like what React and Redux do?
I think maintaining a list of error codes like React is a good idea. 👍
And in longer term we need to create 2 builds, one for development (warnings, errors, useDebugValue) and one for production use (minimal bundle with only error codes).
Related to #339. When the
suspense
option is enabled, SWR can not return any value to continue rendering, neither throwing any promise if it can't fetch. This includes 2 situations:suspense: true
andkey
is falsy.suspense: true
andfetcher
isnull
.In both cases SWR should throw an error.
The text was updated successfully, but these errors were encountered: