dx(suspense): warn when using async setup when not inside a Suspense boundary (#5565)

close #3649
This commit is contained in:
Thorsten Lünborg
2022-04-13 11:36:43 +02:00
committed by GitHub
parent 57ca32b096
commit 053c65bc5e
2 changed files with 31 additions and 2 deletions

View File

@@ -709,7 +709,7 @@ describe('Suspense', () => {
<div v-if="errorMessage">{{ errorMessage }}</div>
<Suspense v-else>
<div>
<Async />
<Async />
</div>
<template #fallback>
<div>fallback</div>
@@ -1232,4 +1232,25 @@ describe('Suspense', () => {
await nextTick()
expect(serializeInner(root)).toBe(`<div>parent<!----></div>`)
})
test('warn if using async setup when not in a Suspense boundary', () => {
const Child = {
name: 'Child',
async setup() {
return () => h('div', 'child')
}
}
const Parent = {
setup() {
return () => h('div', [h(Child)])
}
}
const root = nodeOps.createElement('div')
render(h(Parent), root)
expect(
`A component with async setup() must be nested in a <Suspense>`
).toHaveBeenWarned()
})
})