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

feat: add a warning for invalid arguments with suspense mode #1402

Merged
merged 1 commit into from Aug 29, 2021

Conversation

koba04
Copy link
Collaborator

@koba04 koba04 commented Aug 29, 2021

Fixes #1359.
I've added a warning for invalid arguments with suspense mode.
The check (!key || !fn) is the same validation used in other places.

@codesandbox-ci
Copy link

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.

Latest deployment of this branch, based on commit bd08235:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

@shuding
Copy link
Member

shuding commented Aug 29, 2021

Thanks! 🎉

@shuding
Copy link
Member

shuding commented Aug 29, 2021

Gonna merge this for now, we can fix the CI later.

@shuding shuding merged commit c703e6c into vercel:master Aug 29, 2021
@koba04 koba04 deleted the feat-add-warning-for-suspense-mode branch August 29, 2021 12:19
@koba04
Copy link
Collaborator Author

koba04 commented Aug 29, 2021

Thank you!

@karol-majewski
Copy link

With that change, how are we supposed to fetch conditionally with suspense?

According to the docs, a falsy value should be used when SWR is not supposed to make a call. I did exactly that, and now in v1.0.1 my app doesn't work anymore.

@koba04
Copy link
Collaborator Author

koba04 commented Sep 14, 2021

@karol-majewski Thank you for your feedback, I missed the document and that makes sense for me. I think this is a breaking change with the document and I'll create a PR to revert this.
There are some discussions about how suspense mode behaves with nullish values for key and fetcher (#1412), so we should continue discussing about this.

@karol-majewski
Copy link

@koba04 Thank you for such a quick reaction! 🙇

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.

SWR should throw an error when suspense is enabled but key is not ready
3 participants