yew icon indicating copy to clipboard operation
yew copied to clipboard

How to mount two components to body?

Open kellytk opened this issue 8 years ago • 2 comments

Description

I'm submitting a ...

  • bug report

Rather than having a single child element of the body element my document structure and styling requires two. However, that's causing a panic.

Expected Results

// app.rs
impl Renderable<Model> for Model {
    fn view(&self) -> Html<Self> {
        html! {
            <Component1:/>
            <Component2:/>
        }
    }
}

// index.html
<!doctype html>
<html lang="en">
    <head>
        <link href="file.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <script src="js/app.js"></script>
    </body>
</html>

// rendered.html
<!doctype html>
<html lang="en">
    <head>
        <link href="file.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <div class="component1">...</div>
        <div class="component2">...</div>
    </body>
</html>

Actual Results

The browser panics.

Context (Environment)

  • Rust: v1.30.0-nightly (721913067 2018-08-26)
  • yew: 504ce8b (latest commit)
  • target: wasm32-unknown-unknown
  • cargo-web: v0.6.15

kellytk avatar Oct 22 '18 06:10 kellytk

I guess what you need is Fragment

// app.rs
impl Renderable<Model> for Model {
    fn view(&self) -> Html<Self> {
        html! {
            <>
                <Component1:/>
                <Component2:/>
            </>
        }
    }
}

duytbp avatar Oct 23 '18 10:10 duytbp

Thank you.

kellytk avatar Oct 23 '18 12:10 kellytk