dx(suspense): warn when using async setup when not inside a Suspense boundary (#5565)
close #3649
This commit is contained in:
@@ -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()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user