Skip to content

Return multiple components on the same level #1213

Answered by Archmonger
NewBobCon asked this question in Question
Discussion options

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

Comment options

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy