yew/website/docs/concepts/html/fragments.md
Julius Lungys 8d674c5fda
Add key docs and Move fragments docs (#2178)
* Add key docs

* add frogments to sodebar

* remove duplicate title

* Apply suggestions from code review

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Apply suggestions from code review

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>

* remove html comments

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2021-11-23 09:01:58 +05:00

409 B

title
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").

use yew::html;

html! {
    <>
        <div></div>
        <p></p>
    </>
};
use yew::html;

/* error: only one root html element allowed */

html! {
    <div></div>
    <p></p>
};