We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 78977c3 commit 3e7bb7dCopy full SHA for 3e7bb7d
packages/runtime-core/src/componentOptions.ts
@@ -15,7 +15,8 @@ import {
15
isArray,
16
EMPTY_OBJ,
17
NOOP,
18
- hasOwn
+ hasOwn,
19
+ isPromise
20
} from '@vue/shared'
21
import { computed } from './apiComputed'
22
import { watch, WatchOptions, WatchCallback } from './apiWatch'
@@ -316,6 +317,13 @@ export function applyOptions(
316
317
)
318
}
319
const data = dataOptions.call(ctx, ctx)
320
+ if (__DEV__ && isPromise(data)) {
321
+ warn(
322
+ `data() returned a Promise - note data() cannot be async; If you ` +
323
+ `intend to perform data fetching before component renders, use ` +
324
+ `async setup() + <Suspense>.`
325
+ )
326
+ }
327
if (!isObject(data)) {
328
__DEV__ && warn(`data() should return an object.`)
329
} else if (instance.data === EMPTY_OBJ) {
0 commit comments