@@ -263,6 +263,28 @@ fn App() -> Html {
263
263
}
264
264
```
265
265
266
+ ## Automatically generate properties (autoprops)
267
+
268
+ In order to streamline your development process, you can also use the macro
269
+ ` #[autoprops] ` that will automatically generate the ` Properties ` struct for you.
270
+
271
+ ``` rust
272
+ use yew :: prelude :: * ;
273
+
274
+ #[autoprops]
275
+ #[function_component]
276
+ fn Greetings (
277
+ #[prop_or (" Hello" . into ())]
278
+ message : AttrValue ,
279
+ #[prop_or (" World" . into ())]
280
+ name : AttrValue ,
281
+ ) -> Html {
282
+ html! {<>{message }{name }</ >}
283
+ }
284
+
285
+ // The properties struct "GreetingsProps" will be generated automatically.
286
+ ```
287
+
266
288
## Evaluation Order
267
289
268
290
Props are evaluated in the order they're specified, as shown by the following example:
@@ -296,7 +318,12 @@ These include, but are not limited to:
296
318
** Why is this bad?** Interior mutability (such as with ` RefCell ` , ` Mutex ` , etc.) should
297
319
_ generally_ be avoided. It can cause problems with re-renders (Yew doesn't know when the state has changed)
298
320
so you may have to manually force a render. Like all things, it has its place. Use it with caution.
299
- 3 . You tell us. Did you run into an edge-case you wish you knew about earlier? Feel free to create an issue
321
+ 3 . Using ` Vec ` type instead of ` IArray ` . <br />
322
+ ** Why is this bad?** ` Vec ` , just like ` String ` , can also be expensive to clone. ` IArray ` is either
323
+ a reference-counted slice (` Rc<T> ` ) or a ` &'static [T] ` , thus very cheap to clone.<br />
324
+ ** Note** : ` IArray ` can be imported from [ implicit-clone] ( https://crates.io/crates/implicit-clone )
325
+ See that crate to learn more.
326
+ 4 . You tell us. Did you run into an edge-case you wish you knew about earlier? Feel free to create an issue
300
327
or PR a fix to this documentation.
301
328
302
329
## yew-autoprops
0 commit comments