}
let cleanup: () => void
- const onInvalidate: InvalidateCbRegistrator = (fn: () => void) => {
+ let onInvalidate: InvalidateCbRegistrator = (fn: () => void) => {
cleanup = runner.options.onStop = () => {
callWithErrorHandling(fn, instance, ErrorCodes.WATCH_CLEANUP)
}
// 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) {
defineComponent,
createTextVNode,
createStaticVNode,
- KeepAlive,
withCtx,
- Transition
+ KeepAlive,
+ Transition,
+ watchEffect
} from 'vue'
import { escapeHtml } from '@vue/shared'
import { renderToString } from '../src/renderToString'
const html = await render(app)
expect(html).toBe(`<div>hello</div>`)
})
+
+ // https://github.com/vuejs/vue-next/issues/3322
+ test('effect onInvalidate does not error', async () => {
+ const noop = () => {}
+ const app = createApp({
+ setup: () => watchEffect(onInvalidate => onInvalidate(noop)),
+ render: noop,
+ })
+ expect(await render(app)).toBe('<!---->')
+ })
})
}