mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
* add prettier * ci * run prettier * run prettier in CI * run prettier --write * ignore README.md * specify googleAnalytics * fmt * npm run write-translations * fmt * ignore i18n json files they're autogenerated and don't like being formatted * post merge fixes & some updates * post merge fixes
44 lines
610 B
Plaintext
44 lines
610 B
Plaintext
---
|
|
title: 'Fragments'
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs'
|
|
import TabItem from '@theme/TabItem'
|
|
|
|
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").
|
|
|
|
<Tabs>
|
|
<TabItem value="Valid" label="Valid">
|
|
|
|
```rust
|
|
use yew::prelude::*;
|
|
|
|
html! {
|
|
<>
|
|
<div></div>
|
|
<p></p>
|
|
</>
|
|
};
|
|
|
|
```
|
|
|
|
</TabItem>
|
|
|
|
<TabItem value="Invalid" label="Invalid">
|
|
|
|
```rust, compile_fail
|
|
use yew::prelude::*;
|
|
|
|
// error: only one root html element allowed
|
|
|
|
html! {
|
|
<div></div>
|
|
<p></p>
|
|
};
|
|
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|