Fragments
The html! macro always requires a single root node. In order to get around this restriction, you can use an “empty tag” (these are also called “fragments”).
- Valid
- Invalid
1. use yew::prelude::*;
3. html! {
4. <>
5. <div></div>
6. <p></p>
7. </>
8. };
1. use yew::prelude::*;
3. // error: only one root html element allowed
5. html! {
6. <div></div>
7. <p></p>
8. };
