Skip to content

Commit 0fe0088

Browse files
authored
fix(watch): only trigger warning in the dev environment (#754)
Co-authored-by: webfansplz <>
1 parent f0e423f commit 0fe0088

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/apis/watch.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,23 +298,25 @@ function createWatcher(
298298
} else if (isFunction(s)) {
299299
return s()
300300
} else {
301-
warn(
302-
`Invalid watch source: ${JSON.stringify(s)}.
301+
__DEV__ &&
302+
warn(
303+
`Invalid watch source: ${JSON.stringify(s)}.
303304
A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`,
304-
vm
305-
)
305+
vm
306+
)
306307
return noopFn
307308
}
308309
})
309310
} else if (isFunction(source)) {
310311
getter = source as () => any
311312
} else {
312313
getter = noopFn
313-
warn(
314-
`Invalid watch source: ${JSON.stringify(source)}.
314+
__DEV__ &&
315+
warn(
316+
`Invalid watch source: ${JSON.stringify(source)}.
315317
A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`,
316-
vm
317-
)
318+
vm
319+
)
318320
}
319321

320322
const applyCb = (n: any, o: any) => {

0 commit comments

Comments
 (0)