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 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! - Support Callback 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 the PartialEq, Clone, or Default traits [[@jstarry], #553]
      • Component will not panic if the change method is unimplemented [[@jstarry], #554]
    • ๐Ÿšจ Breaking changes

      • The Component::Properties associated type must implement the new Properties 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 into Option 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<()>,
      }