Subscribe on changes!

OldChildren is null with modified component

avatar
Jul 30th 2022

Vue version

3.2.37

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-n192fc

Steps to reproduce

Open the inspector, to console or debugger and there is a error shown by vue

What is expected?

components should be shown twice on the rendered HTML

What is actually happening?

components are shown once. Every components passed in createClientOnly throws, while the components passed in workaroundClientOnly works

System Info

No response

Any additional comments?

This happened during a fix on Nuxt 3. The createClientOnly function modify component that will render only after the component has been mounted.

A workaround is available by wrapping the render function with a Fragment here (function: workaroundClientOnly)

From what i can understand at the doc, render functions should return a VNode so returning directly the original render function should be working. But on some components that has been modified with createClientOnly(), vue triggers a oldChildren is null error similar to https://github.com/vuejs/core/issues/2820 when it tries to call its original render function after being mounted.

Even if we can workaround this by wrapping the original render function with a Fragment, is this a normal behavior ?