Subscribe on changes!

Problem of not reading parent node when rendering child components through render(h) function

avatar
Apr 2nd 2023

Vue version

^3.2.47

Link to minimal reproduction

https://sfc.vuejs.org/#eNp9kk1OwzAQha8yeEORmnhfWgQq4gCw9cakkyYosa0Zhx9VvTvjJKRNK7Gzx8/fvGfPQT2FkH92qFZqfZNlUHgXbe2QZNUG79BFyLIH44xbc0F1iNBYt98YFdkoqdeioggHqOAIJfkWbgV3ez+ddIxPDVJ8i55wVDxqTjvWNp0k8STfVnWz2069B32uJzes54pkfgY4pI4vGIvqzbcYq9rtJ2cjh+17I82vdAMHv3vODkvbNcIzDsDyjyuAMXZhcTeUIL0VR+gjDOE287CLu553kpap29a7st6LdqQAsPR/ttEu/won5Fg6XoCmqz1x8j8BGm935/te9ooseUbg4HUef3Hm72Tdftl6tH5SXiYL5AOfZ/rHwVUmkmclB/KwmweoFvP/XQ7s1FDuyN10b62HWZT5U0s1fHzW2pB/sHcyyr0NMx7InK7+jBkl45L2RlUxBl5pzWWRZuiDc097LaucOhfrFnPkNnsn/8VIAjZqNN4ztBQ/kTJCt0NC+o95Ib3i9skkmDr+ApKiNww=

Steps to reproduce

(Please understand that English sentences are not smooth because I used a translator.)

I made a container component. The component uses a generic script tag and async setup function (I found out this was a problem!). It receives data by performing API communication within the setup function. Problem occurs when rendering child components while lowering the data to props through the h function.

What is expected?

Child components should be rendered normally.

What is actually happening?

It does not render normally, and the console displays the error "Type Error: Cannot read properties of null (reading 'parentNode'). If this problem occurs, it does not render normally when routing to other routes.

스크린샷 2023-04-03 오전 1 08 30

System Info

No response

Any additional comments?

No response

avatar
Apr 2nd 2023

I removed async from the setup function and created a separate function, and it works fine. It's resolved!

export default {
  setup() { // remove async
  ...
  const loadData = async () => {
      await fetchSomething();
    };
    loadData();
 }
  ...
};

But I want to know why(I'd like to know the details) 😖

avatar
Apr 2nd 2023

Components with an async setup only work when they are descendants of a Suspense component, because that Suspense component essentially awaits the async setup