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

Suspense regression when toggling an async component in rc.12 #2142

Open
cexbrayat opened this issue Sep 17, 2020 · 4 comments
Open

Suspense regression when toggling an async component in rc.12 #2142

cexbrayat opened this issue Sep 17, 2020 · 4 comments

Comments

@cexbrayat
Copy link
Member

Version

3.0.0-rc.12

Reproduction link

https://jsfiddle.net/v0onkyej/

Steps to reproduce

This is based on a comment I added on #3132 but I'm afraid it went unnoticed.
Just to make sure we are not missing anything.

Consider:

<button @click="toggled = !toggled">Toggle {{ toggled }}</button>
<Suspense>
  <div v-if="toggled">
    <hello />
  </div>
  <template #fallback>Loading...</template>
</Suspense>

What is expected?

In rc.10, the Loading indicator is displayed.

What is actually happening?

In rc.12, the Loading indicator is not displayed.

@leopiccionia
Copy link
Contributor

leopiccionia commented Sep 17, 2020

According to #2099, it's an intended change.

By default, the current active tree will stay on the screen until the pending tree is resolved. The pending tree, when resolved, replaces the previous active tree and becomes the new active tree.

A timeout prop can be specified - if a pending tree remains pending past the timeout threshold, the active tree will be unmounted and be replaced by the fallback tree.

If <Suspense> is replaced by <Suspense timeout="0">, for example, the loading... message appears as soon as possible.

It happens because toggled initial value is false, so suspense resolves immediately.

@cexbrayat
Copy link
Member Author

@leopiccionia 👍 I agree, but it's weird to have the fallback tree on first load (if toggled is true), right away (depite having a timeout or not) and not on the following toggles without timeout. If that's expected, I don't mind closing it, but I'd like a confirmation. I personally think it was more intuitive previously and was afraid this behavior was not really intended.

@yyx990803
Copy link
Member

@leopiccionia 's interpretation is correct. However, I agree this is still open to discussion. Maybe we should default the timeout to 0 which encourages users to always set a timeout.

@Ydot19
Copy link

Ydot19 commented Sep 22, 2020

I think setting a timeout to encourage users is the better alternative because it gives more clarity about the code should behave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants