0.8.0
版本发布时间: 2019-08-11 07:25:45
yewstack/yew最新发布版本:yew-v0.21.0(2023-09-29 19:14:55)
Props! Props! Props!
This release introduces a more developer friendly way to handle your Component
props. Use the new #[derive(Properties)]
macro to beef up your props! Property values can now be annotated as #[props(required)]
which will enforce that props are present at compile time. This means that your props struct no longer needs to implement Default
, so time to clean up all of those prop values you wrapped in Option
to have a default value.
-
⚡️ Features
-
html!
- Self-closing html tags can now be used:<div class="marker" />
[@totorigolo, #523] -
html!
- SVG name-spaced tags are now supported! [@jstarry, #550] - Properties can now be required at compile time [@jstarry, #553]
- App components can now be mounted with properties [@jstarry, #567]
- Apps can now be mounted as the
<body>
tag [@jstarry, @kellytk, #540] - Content editable elements can now trigger
oninput
events [@tiziano88, #549]
-
-
🛠 Fixes
-
html!
- Class name order is now preserved which unlocks the use of Semantic UI [@charvp, #424] -
html!
- Dashed tag names and properties are supported [@jstarry, #512, #550] -
html!
- All rust keywords can be used as tag attributes [@jstarry, #550] -
html!
- SupportCallback
closure with explicit return type [@totorigolo, #564] -
html!
- Fixed edge case where>
token would break parser [@totorigolo, #565] - Performance improvement to the diff engine [@totorigolo, #539]
-
Properties
no longer need to implement thePartialEq
,Clone
, orDefault
traits [@jstarry, #553] -
Component
will not panic if thechange
method is unimplemented [@jstarry, #554]
-
-
🚨 Breaking changes
-
The
Component::Properties
associated type must implement the newProperties
trait [@jstarry, #553]The new
Properties
trait is what powers the ability to check required props are present at compile time. Use the derive props macro to implement automatically.use yew::Properties; #[derive(Properties)] pub struct Props { #[props(required)] pub value: MyStruct, }
-
Callback
props no longer transform intoOption
types [@jstarry, #553]html! { <Button on_click=Msg::Click /> }
before:
#[derive(PartialEq, Clone, Default)] pub struct Props { on_click: Option<Callback<()>>, }
after: note the
#[props(required)]
attribute#[derive(PartialEq, Properties)] pub struct Props { #[props(required)] on_click: Callback<()>, }
-