Skip to content

Return multiple components on the same level #1213

Answered by Archmonger
NewBobCon asked this question in Question

You must be logged in to vote

For your scenario of

<body>
    <header>MyHeader</header>
    <main>The main content</main>
    <footer>MyFooter</footer>
</body>

If you want to structure it as "multiple components on the same level", your second example is correct.
You need to use a parent HTML element, in this case html._ (a HTML fragment), to "encapsulate" things that are within the same level.

@component
def App():
    return html._(header(), main(), footer())

You can not directly return an iterable as a top-level root node within your component (such as your return (header(), main(), footer()) example.

Replies: 1 comment

You must be logged in to vote
0 replies
Answer selected by Archmonger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants