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

Possible edge scenario when using Conditional Fetching + Suspense mode #372

Closed
ythecombinator opened this issue May 5, 2020 · 3 comments

Comments

@ythecombinator
Copy link

The docs state that:

In Suspense mode, data is always the fetch response (so you don't need to check if it's undefined).

It turns out that if we use suspense mode + conditional fetching, SWR is going to suspend the execution only when it gets a valid id, resulting in an undefined data object meanwhile.

As a user, I would expect that SWR throws component rendering at the moment of invocation, even — if the fetcher execution hasn't started yet — because right now I end up having to do undefined checks anyway.

Here's a working sample: https://codesandbox.io/s/conditional-fetching-suspense-b72ii

I am not quite sure if that's actually the intended behavior. If so, I'd say it definitely deserves some notice on the docs.

Also, I tried finding some similar issues but I couldn't find any related one.

Thanks 🙏

@sergiodxa
Copy link
Contributor

I think this solves your use case #357?

@ythecombinator
Copy link
Author

Yeah, definitely, I'd say.

Actually, mine could be considered duplicate in face of #339. I somehow missed it when searching Github 😓

@shuding
Copy link
Member

shuding commented May 12, 2020

Duplicate of #339, closing this one for now 🙏

@shuding shuding closed this as completed May 12, 2020
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

No branches or pull requests

3 participants