yew v0.8 Release Notes
Release Date: 2019-08-10 // over 4 years ago-
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 implementDefault
, so time to clean up all of those prop values you wrapped inOption
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<()>, }
- The