yew
yew copied to clipboard
How to mount two components to body?
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
I guess what you need is Fragment
// app.rs
impl Renderable<Model> for Model {
fn view(&self) -> Html<Self> {
html! {
<>
<Component1:/>
<Component2:/>
</>
}
}
}
Thank you.