fix(ssr): watchEffect onInvalidate runner initialization (#3323)
close #3322
This commit is contained in:
@@ -223,7 +223,7 @@ function doWatch(
|
||||
}
|
||||
|
||||
let cleanup: () => void
|
||||
const onInvalidate: InvalidateCbRegistrator = (fn: () => void) => {
|
||||
let onInvalidate: InvalidateCbRegistrator = (fn: () => void) => {
|
||||
cleanup = runner.options.onStop = () => {
|
||||
callWithErrorHandling(fn, instance, ErrorCodes.WATCH_CLEANUP)
|
||||
}
|
||||
@@ -232,6 +232,8 @@ function doWatch(
|
||||
// in SSR there is no need to setup an actual effect, and it should be noop
|
||||
// unless it's eager
|
||||
if (__NODE_JS__ && isInSSRComponentSetup) {
|
||||
// we will also not call the invalidate callback (+ runner is not set up)
|
||||
onInvalidate = NOOP
|
||||
if (!cb) {
|
||||
getter()
|
||||
} else if (immediate) {
|
||||
|
||||
Reference in New Issue
Block a user