mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Add #[derive(Clone)] in examples (#111)
* Add #[derive(Clone)] in examples Closes #110 * Add backticks to rust elements Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com> * Another backtics Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
This commit is contained in:
parent
840b0aa4ae
commit
6a07d91b37
@ -42,7 +42,7 @@ html! {
|
||||
```rust
|
||||
pub struct Container(Props);
|
||||
|
||||
#[derive(Properties)]
|
||||
#[derive(Properties, Clone)]
|
||||
pub struct Props {
|
||||
pub children: Children,
|
||||
}
|
||||
@ -63,6 +63,8 @@ impl Component for Container {
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
{% hint style="info" %} Types for which you derive `Properties` must also implement `Clone`. This can be done by either using `#[derive(Properties, Clone)]` or manually implementing `Clone` for your type. {% endhint %}
|
||||
|
||||
## Nested Children with Props
|
||||
|
||||
Nested component properties can be accessed and mutated if the containing component types its children.
|
||||
@ -86,7 +88,7 @@ html! {
|
||||
```rust
|
||||
pub struct List(Props);
|
||||
|
||||
#[derive(Properties)]
|
||||
#[derive(Properties, Clone)]
|
||||
pub struct Props {
|
||||
pub children: ChildrenWithProps<ListItem>,
|
||||
}
|
||||
@ -107,4 +109,3 @@ impl Component for List {
|
||||
}
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user