Skip to content

Commit f9b776c

Browse files
zoechijstarry
andauthored
Mention prop_or macro (yewstack#97)
* Mention prop_or macro * Fix the prop_or vs prop_or_else mixup * Update src/concepts/components/properties.md Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
1 parent 9594b47 commit f9b776c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

‎src/concepts/components/properties.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Types for which you derive `Properties` must also implement `Clone`. This can be
1616

1717
### Required attributes
1818

19-
The fields within a struct that derives `Properties` are required by default. When a field is missing and the component is created in the `html!` macro, a compiler error is returned. For fields with optional properties, use the `#[prop_or_default]` attribute to use the default value for that type when the prop is not specified. To specify a value, use the `#[prop_or_else(value)]` attribute where value is the default value for the property. For example, to default a boolean value as `true`, use the attribute `#[prop_or_else(true)]`. It is common for optional properties to use the `Option` enum which has the default value `None`.
19+
The fields within a struct that derives `Properties` are required by default. When a field is missing and the component is created in the `html!` macro, a compiler error is returned. For fields with optional properties, use the `#[prop_or_default]` attribute to use the default value for that type when the prop is not specified. To specify a value, use the `#[prop_or(value)]` attribute where value is the default value for the property or alternatively use `#[prop_or_else(function)]` where `function` returns the default value. For example, to default a boolean value as `true`, use the attribute `#[prop_or(true)]`. It is common for optional properties to use the `Option` enum which has the default value `None`.
2020

2121
### PartialEq
2222

@@ -72,4 +72,3 @@ pub struct LinkProps {
7272
active: bool,
7373
}
7474
```
75-

0 commit comments

Comments
 (0)