question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Vue warn]: Multiple root nodes returned from render function. Render function should return a single root node.

See original GitHub issue

When having a construct like this for a component, I get the following error due to the reason that the funcational component returns actually two elements.

<template>
    <no-ssr>
       lalala
    </no-ssr>
</template>

Error I get: [Vue warn]: Multiple root nodes returned from render function. Render function should return a single root node.

I guess it has somethign todo with the return value of the render function:

return h(
      props.placeholderTag,
      {
        class: ['no-ssr-placeholder']
      },
      props.placeholder || placeholderSlot
)

How can I ensure that in this case there is actually only one element returned (I don’t need a placeholder)

Thanks Simon

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
egoistcommented, Oct 8, 2018

<no-ssr> renders the default slot which is an array when mounted:

https://github.com/egoist/vue-no-ssr/blob/f9b6f194121b4937bed4846b9fbc8f01fd06e75b/src/index.js#L14-L16

so you can’t use this component at root level, instead:

<template>
  <div>
    <no-ssr>
       ....
    </no-ssr>
  </div>
</template>
1reaction
egoistcommented, Nov 15, 2018

@Yimiprod the docs didn’t say that

update: well it did, but that has been removed since 1.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Multiple root nodes returned from render function" error with ...
"Multiple root nodes returned from render function. Render function should return a single root node." error in console, nothing render.
Read more >
Error in vue.js (Multiple root nodes returned from render ...
Your createComponent returns an array of VNodes on line 9 . It seems that you are always passing an array of node definitions...
Read more >
Error: Multiple root nodes returned from render function. from v ...
If that slot contains multiple items then they'll all be returned, leading to the error you're seeing. Try wrapping the two nodes in...
Read more >
Can A Vue Template Have Multiple Root Nodes (Fragments)?
Rendering a list of child nodes in a component is not a design pattern that works with Vue due to the single root...
Read more >
Can a Vue Template Have Multiple Root Nodes (Fragments)?
You'll get a compilation and/or runtime error, as templates must have a single root element. Typically, you'll fix this problem by adding a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found