NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #5178 most downloaded on crates.io
A framework for making client-side single-page apps
Latest stable
0.23.0
Last release 8 months ago
10 Mar 2026
Release timing varies
gaps range from 1 weeks to 2.2 years
Nearly every release is documented
notes for 20 of 21 stable releases
4 versions withdrawn
withdrawn after publishing
7 years old
25 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
bumping from 0.22 should require no code changes for most users.
bumping from 0.22 should require no code changes for most users.
&str and String can now be used for props of type Option<Html>. [@Casheeew, #4020]scheduler::flush function to reliably finish rendering. Useful in testing as a replacement for timeouts. [@Madoshakalaka, #4044]Nones are now allowed for Option<T> props in the html! macro. [@Madoshakalaka, #4021]Your coding agent can read these notes before it upgrades. Set up the MCP server →
bumping from 0.22 should require no code changes for most users.
&str and String can now be used for props of type Option<Html>. [@Cashew, #4020]scheduler::flush function to reliably finish rendering. Useful in testing as a replacement for timeouts. [@Siyuan Yan, #4044]Nones are now allowed for Option<T> props in the html! macro. [@Siyuan Yan, #4021]Domslot hydration panic caused by suspension [@Siyuan Yan, #4003]
Option<T> and &T types can be used as children again. e.g. Option<AttrValue> [@Siyuan Yan, #4005]from_html_unchecked [@Jason Heard, #3970]Remove deprecated class=(...) syntax. [ @its-the-shrimp , #3497 ]
class=(...) syntax. [@its-the-shrimp, #3497]<textarea> a void element (no children allowed anymore). [@its-the-shrimp, #3465]html! macro. [@its-the-shrimp, #3498]#[function_component] to #[component]. [@its-the-shrimp, #3885]serde feature to yew. [@its-the-shrimp, #3880]use_ref hook. [@ColonelThirtyTwo, #3548]html! macro. [@cecton, #3508, #3431] [@Madoshakalaka, #3892]inert to the boolean attributes list. [@kawadakk, #3678]VRaw. [@finnbear, #3640]to_callback methods and From impls to convert reducer dispatchers and state setters to callbacks. [@its-the-shrimp, #3519]ChildrenRenderer<VNode> and VChild to VList. [@ranile, #3444]CallbackRef that takes ref in argument instead of value. [@cecton, #3419]UseFutureHandle Clone. [@AdamSteinberg1, #3529]Self in prop fields. [@its-the-shrimp, #3569]html!. [@its-the-shrimp, #3441]html!. [@its-the-shrimp, #3441]#[hook]: clippy::multiple_bound_locations lint no longer triggered. [@its-the-shrimp, #3803]boolinator. [@its-the-shrimp, #3420]FromQuery and IntoQuery traits. [@Roba1993, #3565]class=(...) syntax. [@Tim Kurdov, #3497]<textarea> a void element (no children allowed anymore). [@Tim Kurdov, #3465]html! macro. [@Tim Kurdov, #3498]#[function_component] to #[component]. [@Tim Kurdov, #3885]serde feature to yew. [@Tim Kurdov, #3880]use_ref hook. [@Alex Parrill, #3548]html! macro. [@Cecile Tonglet, #3508, #3431] [@Siyuan Yan, #3892]inert to the boolean attributes list. [@Tomoaki Kawada, #3678]VRaw. [@Finn Bear, #3640]to_callback methods and From impls to convert reducer dispatchers and state setters to callbacks. [@Tim Kurdov, #3519]ChildrenRenderer<VNode> and VChild to VList. [@Muhammad Hamza, #3444]CallbackRef that takes ref in argument instead of value. [@Cecile Tonglet, #3419]UseFutureHandle Clone. [@Adam Steinberg, #3529]Self in prop fields. [@Tim Kurdov, #3569]html!. [@Tim Kurdov, #3441]html!. [@Tim Kurdov, #3441]#[hook]: clippy::multiple_bound_locations lint no longer triggered. [@Tim Kurdov, #3803]boolinator. [@Tim Kurdov, #3420]Update Dependencies with Breaking Changes by @futursolo in #3204
start_app migration section. by @alexschrod in #3016web_worker_fib example use a relative path for the web worker by @kaisalmon in #3057html! macro for IntelliJ Rust plugin by @vlad20012 in #2972awesome.md by @eliaperantoni in #3207Note truncated.
Users can follow the migration guide to migrate from 0.20.0 to 0.21.0.
set_event_bubbling. [[@Tim Kurdov](https://github.com/Tim Kurdov), #3391]IntoPropValue implementation to convert from Cows to AttrValue. [[@Tim Kurdov](https://github.com/Tim Kurdov), #3346]Option in derive(Properties). [[@Tim Kurdov](https://github.com/Tim Kurdov), #3398]'/' is no longer wrongly encoded in wildcard route segments. [ @Madoshakalaka , #4056 ]
Yew pinned to 0.23 now.
/basename//basename resulting in a 404. [@Madoshakalaka, #4030]Yew pinned to 0.23 now.
/basename//basename resulting in a 404. [@Siyuan Yan, #4030]Nothing published for this version
Nothing published for this version
Nothing published for this version
Introduce FromQuery and IntoQuery traits. [@Robert Schütte, #3565]
FromQuery and IntoQuery traits. [@Robert Schütte, #3565]Fix missing redirects. [@siku2, #1640]
Allow agents to send input messages to themselves. [[@mkawalec], #1278]
Allow agents to send input messages to themselves. [@mkawalec, #1278]
Rendering performance has been improved by ~20%. [@jstarry, #1296, #1309]
html!: Elements can be specified with dynamic tag names. [@siku2, #1266]
In order to specify a dynamic tag name, wrap an expression with @{..}:
let tag_name = "input";
html! { <@{tag_name} value="Hello" /> }
HTML button element type can now be specified ("submit", "reset", or "button"). [@captain-yossarian, #1033]
All global event listeners can be used as listeners (onerror, onloadend, and many more). [@siku2, #1244]
PartialEq is now implemented for VChild when properties also implement PartialEq. [@kellpossible, #1242]
Agent callbacks now accept Into<Message> to improve ergonomics. [@totorigolo, #1215]
Agents can now send messages to themselves. [@totorigolo, #1215]
Bincode dependency version has been loosened 1.2.1 -> 1. [@jstarry, #1349]
Keyed list ordering algorithm has been fixed. [@totorigolo and @jstarry, #1231]
html!: key and ref are no longer ignored for components with no properties. [@jstarry, #1338]
html!: List rendering behavior is consistent no matter which syntax is chosen. [@siku2, #1275]
html! { for node_list } is now equivalent to html! { node_list } when node_list is a Vec<VNode>.
KeyboardService events can now have default behavior prevented. [@ghpu, #1286]
Yew will check the current DOM input value before comparing with the desired value. [@ShadoySV, #1268]
html!: Void elements (<br/>, <input />) are no longer allowed to have children. [@kaoet, #1217]
Local agents no longer require Input and Output to implement Serializable. [@mkawalec, #1195]
Renders are now done lazily and will not be executed until all updates have been processed. [@jstarry, #1309]
ConsoleService, DialogService, IntervalService, RenderService, TimeoutService, and WebSocketService methods are now static. [@teymour-aldridge, #1313]
html!: Children no longer implements Renderable. [@siku2, #1275]
Replace instances of self.props.children.render() with self.props.children.clone().
Yew no longer stops propagation of events by default. [@jstarry, #1256]
Event propagation is usually stopped when you have event listeners attached to nested elements and do not want the event to bubble up from where it was first captured. If your app has this behavior, you can stop propagation by calling stop_propagation() on the desired event.
The onsubmit listener now uses FocusEvent instead Event when using web-sys. [@siku2, #1244]
The onmousewheel and ontouchenter listeners have been removed. [@siku2, #1244]
The ondoubleclick listener is now named ondblclick. [@siku2, #1244]
FetchService methods are now static. [@teymour-aldridge, #1235]
Instead of FetchService::new().fetch(..) you should now use FetchService::fetch(..)
The send_message_batch method has been removed from AgentLink. [@totorigolo, #1215]
Minimum supported rust version has been bumped from 1.40.0 to 1.42.0. [@mkawalec, #1195]
Every agent Reach type is now generic. [@mkawalec, #1195]
In order to fix your app, simply append <Self> to the reach:
Reach = Context -> Reach = Context<Self>
Removed Global agent because it was never implemented. [@jstarry, #1202]
Reduced visibility of internal agent types that were not intended to be public. [@jstarry, #1202]
NodeRef passing to <Link> for yew-router. [[@Athan Clark](https://github.com/Athan Clark), #2877]#[cfg(feature = "render")] and yew::Renderer. [[@Kaede Hoshikawa](https://github.com/Kaede Hoshikawa), #2498]Worker script is now loaded from absolute path. [[@domdir], #1175]
Added optional id, class, and placeholder properties to the Select component. [[@Stigjb], #1187]
Added optional id, class, and placeholder properties to the Select component. [@Stigjb, #1187]
Re-export web-sys from Yew. This allows projects to use web-sys without adding it to their Cargo.toml. [@D4nte, #1176]
Added support for Option wrapped class names. [@liquidblock, #1085]
The following code is now supported:
let color: &Option<String> = &self.color;
html! { <div class=("btn", color)></div> }
Added get_parent and get_component methods to ComponentLink to allow access to parent component state. [@jstarry, #1151]
Private worker lifecycle event sending. [@joaquindk, #1146]gloo_utils instead of re-implementing them. [@hamza1311, #2124]yew now uses web-sys by default. If your project uses web-sys, you can now drop the "web_sys" feature from your yew dependency. Don't worry stdweb use
yew now uses web-sys by default. If your project uses web-sys, you can now drop the "web_sys" feature from your yew dependency.
Don't worry stdweb users, we have created a new alias crate for y'all called yew-stdweb. In order to use it, update your Cargo.toml yew dependency to the following:
yew = { version = "0.15", package = "yew-stdweb" }
Thank you to everyone that took the time to fill out the Yew Dev Survey! 🙇♂️
Results have been posted here: https://github.com/yewstack/yew/wiki/Dev-Survey-%5BSpring-2020%5D
We moved from Gitter to Discord! Join us: https://discord.gg/VQck8X4
tuple or Vec. [@bryanjswift, #1084]components module has been moved out yew and into yew-components. [@jstarry, #1132]mounted component lifecycle method with rendered which is called after each render. [@jstarry, #1072]change method (forgetting this was a very common issue). [@jstarry, #1071]web-sys by default. [@jstarry, #1092]RouterButton now prevents default events per default @TheNeikosConnected message was only called for first bridge creation. [[@nicklaswj], #1029]
Connected message was only called for first bridge creation. [@nicklaswj, #1029]Happy 🥧 (PI) Day! This release brings a number of bug fixes for web-sys apps and ergonomic improvements to the API. Huge thanks to the community for d
Happy 🥧 (PI) Day! This release brings a number of bug fixes for web-sys apps and ergonomic improvements to the API. Huge thanks to the community for diving into the migration from stdweb to web-sys so quickly and uncovering these issues!
Clone for WebSocketStatus. [@kellytk, #1023]Into<Msg>. [@captain-yossarian, #999]html! improved compiler messages and flexible syntax for with props. [@captain-yossarian, #960]stdweb ResizeService event handling. [@nicklaswj, #1014]web-sys workers by updating gloo. [@jstarry, #1018]Connected message for Public agents. [@TheNeikos, #1007]web-sys Public / Private agent initialization. [@jstarry, #1006]web-sys agents. [@jstarry, #1005]FetchError::FetchFailed enum variant now wraps a String to hold the failure reason. [@jstarry, #1025]Into<Msg>, so calling msg.into() will cause compile errors. [@captain-yossarian, #999]unit_state module has been removed.yew version to 0.17.[@daxpedda] spear-headed the effort and courageously integrated web-sys while maintaining support for stdweb through no small amount of cfg macro usag
web-sys support has arrived!@daxpedda spear-headed the effort and courageously integrated web-sys while maintaining support for stdweb through no small amount of cfg macro usage. We chose to continue support for apps built with stdweb because the dev experience is still quite a bit better (Unfortunately cargo-web is incompatible with web-sys). However, the Yew team recognizes that the future of cargo-web of stdweb are uncertain. For this reason, we recommend devs start making the switch over to web-sys and wasm-bindgen. We will likely invest in improving the dev experience with these tools so that switching over is eventually a no-brainer. Please reach out with ideas and feedback for this migration through Github issues and in our Gitter chatroom!
After upgrading to v0.13, devs will now have to opt in to either stdweb or web-sys by using either the "web_sys" or "std_web" on the yew crate in their Cargo.toml.
# Choose `stdweb`
yew = { version = "0.13", features = ["std_web"] }
# Choose `web-sys`
yew = { version = "0.13", features = ["web_sys"] }
Lastly, take note that API docs on https://docs.rs/yew will be using the "web_sys" feature. For "std_web" docs, please visit https://docs.rs/yew-stdweb.
Added support for building apps with web-sys. [@daxpedda, #961]
Properties 2.0 [@AlephAlpha, #975]
Component properties are now assumed to be required unless otherwise annotated with a default value. Check out the proposal issue #928 for more details!
Component children re-rendering bug. [@jstarry, #980]VRef node is detached. [@jstarry, #983]VTag node is detached. [@jstarry, #983]Properties macro behavior. Check out the proposal issue #928 for more details! [@AlephAlpha, #975]ReaderService methods now return a Result instead of panicking. [@daxpedda, #868]FetchService methods now return a Result instead of panicking. [@daxpedda, #867]StorageService methods now return a Result instead of panicking. [@daxpedda, #827]…the Yew community. Take special care of the few breaking changes.
Happy (belated) Valentine's Day for all who ♥️ Yew! Yew ♥️'s you too! This release, as always, packs a bunch of fixes and features from the Yew community. Take special care of the few breaking changes.
html! { for .. }. [@jstarry, #875]#[props(default = "fn_path")] for specifying a default property value. [@AlephAlpha, #881]WebSocketService. [@ctm, #851]PartialEq for ChildrenRenderer to allow children comparison. [@jstarry, #916]ComponentLink methods to improve Future support. [@jplatte, #931]referrer, referrer_policy and integrity to FetchOptions. [@leo-lb, #931]yew version to 0.15.guide example.This release comes with a lot of breaking changes. We understand it's a hassle to update projects but the Yew team felt it was necessary to rip a few…
This release aims to lay the groundwork for Yew component libraries as well as clean up the API for the ever elusive 1.0 release 😜
This release comes with a lot of breaking changes. We understand it's a hassle to update projects but the Yew team felt it was necessary to rip a few bandaids off now as we approach a 1.0 release in the (hopefully) near future. To ease the transition, here's a guide which outlines the main refactoring you will need to do for your project. (Note: all of the changes are reflected in the many example projects if you would like a proper reference example)
This is the main painful breaking change. It applies to both element listeners as well as Component callback properties. A good rule of thumb is that your components will now have to retain a ComponentLink to create callbacks on demand or initialize callbacks in your component's create() method.
Before:
struct Model;
enum Msg {
Click,
}
impl Component for Model {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
Model
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Click => true,
}
}
fn view(&self) -> Html<Self> {
// BEFORE: Callbacks were created implicitly from this closure syntax
html! {
<button onclick=|_| Msg::Click>{ "Click me!" }</button>
}
}
}
After:
struct Model {
link: ComponentLink<Self>,
}
enum Msg {
Click,
}
impl Component for Model {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
Model { link }
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Click => true,
}
}
fn view(&self) -> Html {
// AFTER: Callbacks need to be explicitly created now
let onclick = self.link.callback(|_| Msg::Click);
html! {
<button onclick=onclick>{ "Click me!" }</button>
}
}
}
If a closure has a parameter you will now need to specify the parameter's type. A tip for finding the appropriate type is to search Yew's repo for the HTML attribute the closure is assigned to.
For example, onkeydown of <button>:
let onkeydown = self.link.callback(|e: KeyDownEvent| {
// ...
});
and
html! {
<button onkeydown=onkeydown type="button">
{ "button" }
</button>
}
It should be safe to do a project-wide find/replace for the following:
send_self( -> send_message(send_back( -> callback(response( -> respond(AgentUpdate -> AgentLifecycleEventThese renames will probably require some more care:
fn handle( -> fn handle_input( (for Agent trait implementations)Html<Self> -> Html:tada: We are pretty excited about this change! The generic type parameter was confusing and restrictive and is now a thing of the past!
Before:
impl Component for Model {
// ...
fn view(&self) -> Html<Self> {
html! { /* ... */ }
}
}
After:
impl Component for Model {
// ...
fn view(&self) -> Html {
html! { /* ... */ }
}
}
CloneIn yew v0.8 we removed the requirement that component properties implement Clone
and in this release we are adding the requirement again. This change is needed
to improve the ergonomics of nested components. The only time properties will be
cloned is when a wrapper component re-renders nested children components.
html_nested! macro to support nested iterable children access. [@trivigy, #843]bincode to the list of supported formats. [@serzhiio, #806]noop() convenience method to Callback which creates a no-op callback. [@mdtusz, #793]html! macro now accepts a Callback for element listeners. [@jstarry, #777]struct Model {
onclick: Callback<ClickEvent>,
}
enum Msg {
Click,
}
impl Component for Model {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
Model {
onclick: link.callback(|_| Msg::Click),
}
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Click => true,
}
}
fn view(&self) -> Html {
html! {
<button onclick=&self.onclick>{ "Click me!" }</button>
}
}
}
send_message_batch method to ComponentLink. [@hgzimmerman, #748]wasi target without wasm_bindgen. [@dunnock, #746]AgentLink now implements Clone which enables Future usage without explicit Yew framework support. [@izissise, #802]ComponentLink now implements Clone which enables Future usage without explicit Yew framework support. [@hgzimmerman, #749]use wasm_bindgen::JsValue;
use wasm_bindgen_futures::future_to_promise;
// future must implement `Future<Output = Component::Message> + 'static`
let link = self.link.clone();
let js_future = async move {
link.send_message(future.await);
Ok(JsValue::NULL)
};
future_to_promise(js_future);
fn view(&self) -> Html {
html! {
<Wrapper>
// This is now valid. (before #780, this would cause a lifetime
// compile error because children nodes were moved into a closure)
<Nested on_click=&self.nested_on_click />
</Wrapper>
}
}
Callback with ComponentLink is no longer restricted to mutable references, improving ergonomics. [@jstarry, #780]Callback reform method no longer consumes self making it easier to "reverse map" a Callback. [@jstarry, #779]pub struct ListHeader {
props: Props,
}
#[derive(Properties, Clone)]
pub struct Props {
#[props(required)]
pub on_hover: Callback<Hovered>,
#[props(required)]
pub text: String,
}
impl Component for ListHeader {
type Message = ();
type Properties = Props;
fn create(props: Self::Properties, _: ComponentLink<Self>) -> Self {
ListHeader { props }
}
fn update(&mut self, _: Self::Message) -> ShouldRender {
false
}
fn view(&self) -> Html {
let onmouseover = self.props.on_hover.reform(|_| Hovered::Header);
html! {
<div class="list-header" onmouseover=onmouseover>
{ &self.props.text }
</div>
}
}
}
Classes to_string method. [@hgzimmerman, #772]html! { <Wrapper<String>></Wrapper<String>>}) [@jstarry, #837]VTag listener type from Box<dyn Listener> to Rc<dyn Listener>. [@jstarry, #786]Properties need to implement Clone again in order to improve nested component ergonomics. [@jstarry, #786]send_future method from ComponentLink since it is no longer necessary for using Futures with Yew. [@hgzimmerman, #799]Html and all virtual node types: VNode, VComp, VTag, VList, VText, etc. [@jstarry, #783]Callback explicitly instead). [@jstarry, #782]Agent methods and event type for clarity. handle -> handle_input, AgentUpdate -> AgentLifecycleEvent, response -> respond. [@philip-peterson, #751]ComponentLink send_back method has been renamed to callback for clarity. [@jstarry, #780]ComponentLink send_self and send_self_batch methods have been renamed to send_message and send_message_batch for clarity. [@jstarry, #780]Agent send_back method has been renamed to callback for clarity. [@jstarry, #780]VTag children value type has changed from Vec<VNode> to VList. [@jstarry, #754]Future support :tada: A Component can update following the completion of a Future. Check out this example to see how it works. This approach was borro
Back to the...
Future support :tada: A Component can update following the completion of a Future. Check out this example to see how it works. This approach was borrowed from a fork of Yew called plaster created by @carlosdp. [@hgzimmerman, #717]agent and services features so that those modules can be disabled (useful if you are switching to using Futures). [@hgzimmerman, #684]ref keyword for allowing a Component to have a direct reference to its rendered elements. For example, you can now easily focus an <input> element after mounting. [@jstarry, #715]use stdweb::web::html_element::InputElement;
use stdweb::web::IHtmlElement;
use yew::*;
pub struct Input {
node_ref: NodeRef,
}
impl Component for Input {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
Input {
node_ref: NodeRef::default(),
}
}
fn mounted(&mut self) -> ShouldRender {
if let Some(input) = self.node_ref.try_into::<InputElement>() {
input.focus();
}
false
}
fn update(&mut self, _: Self::Message) -> ShouldRender {
false
}
fn view(&self) -> Html<Self> {
html! {
<input ref=self.node_ref.clone() type="text" />
}
}
}
Agent related types public to allow other crates to create custom agents. [@dunnock, #721]Component::change will now return false for components that have Component::Properties == (). [@kellytk, #690]]wasm-bindgen dependency to 0.2.54. Please update your wasm-bindgen-cli tool by running cargo install --force --version 0.2.54 -- wasm-bindgen-cli. [@jstarry, #730], [@ctaggart, #681]Debug. [@hgzimmerman, #673]Minimum rustc version has been bumped to 1.39.0 for Future support. [@jstarry, #730]
Component now has a required view method and automatically implements the Renderable trait. The view method in the Renderable trait has been renamed to render. [@jstarry, #563]
Before:
impl Component for Model {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
Model {}
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
true
}
}
impl Renderable<Model> for Model {
fn view(&self) -> Html<Self> {
html! { "hello" }
}
}
After:
impl Component for Model {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
Model {}
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
true
}
fn view(&self) -> Html<Self> {
html! { "hello" }
}
}
Removed the Transferable trait since it did no more than extend the serde Serialize and Deserialize traits. [@hgzimmerman, #319]
Before:
impl Transferable for Input {}
#[derive(Serialize, Deserialize)]
pub enum Input {
Connect,
}
After:
#[derive(Serialize, Deserialize)]
pub enum Input {
Connect,
}
WebSocketService::connect will now return a Result in order to stop panicking on malformed urls. [@lizhaoxian, #727]
VTag now is boxed within VNode to shrink the size of its enum representation. [@hgzimmerman, #675]
Fixed yew-macro dependency version
Fixed yew-macro dependency version
Implemented Default trait for VNode so that unwrap_or_default can be called on Option >. [[@hgzimmerman], #672]
Happy Canadian Thanksgiving! 🦃
Default trait for VNode so that unwrap_or_default can be called on Option<Html<Self>>. [@hgzimmerman, #672]PartialEq trait for Classes so that is more ergonomic to use Classes type in component props. [@hgzimmerman, #680]wasm-bindgen dependency to 0.2.50. Please update your wasm-bindgen-cli tool by running cargo install --force --version 0.2.50 -- wasm-bindgen-cli. [@jstarry, #695]ryu downstream dependency. [@jstarry, #703]stdweb to 0.4.20 which fixed emscripten builds and unblocked updating wasm-bindgen to 0.2.50. [@ctaggart, @jstarry, #683, #694]dyn keywords. [@benreyn, #687]This release introduces a slew of new features, many of which come from first-time contributors! There's too many to mention so read more below 😄 Also
Feature Overload
This release introduces a slew of new features, many of which come from first-time contributors! There's too many to mention so read more below 😄 Also, a long-standing bug was fixed by @hgzimmerman which was causing Component's to not be destroyed properly.
New KeyboardService for setting up key listeners on browsers which support the feature. [@hgzimmerman, #647]
ComponentLink can now create a Callback with more than one Message. The Message's will be batched together so that the Component will not be re-rendered more than necessary. [@stkevintan, #660]
Message's to Public Agent's will now be queued if the Agent hasn't finished setting up yet. [@serzhiio, #596]
Agent's can now be connected to without a Callback. Instead of creating a bridge to the agent, create a dispatcher like so: MyAgent::dispatcher(). [@hgzimmerman, #639]
Component's can now accept children in the html! macro. [@jstarry, #589]
// app.rs
html! {
<MyList name="Grocery List">
<MyListItem text="Apples" />
</MyList>
}
// my_list.rs
use yew::prelude::*;
pub struct MyList(Props);
#[derive(Properties)]
pub struct Props {
#[props(required)]
pub name: String,
pub children: Children<MyListItem>,
}
impl Renderable<MyList> for MyList {
fn view(&self) -> Html<Self> {
html! {{
self.props.children.iter().collect::<Html<Self>>()
}}
}
}
Iterators can now be rendered in the html! macro without using the for keyword. [@hgzimmerman, #622]
Before:
html! {{
for self.props.items.iter().map(renderItem)
}}
After:
html! {{
self.props.items.iter().map(renderItem).collect::<Html<Self>>()
}}
Closures are now able to be transformed into optional Callback properties. [@Wodann, #612]
Improved CSS class ergonomics with new Classes type. [@DenisKolodin, #585], [@hgzimmerman, #626]
Touch events are now supported <div ontouchstart=|_| Msg::TouchStart> [@boydjohnson, #584], [@jstarry, #656]
The Component trait now has an mounted method which can be implemented to react to when your components have been mounted to the DOM. [@hgzimmerman, #583]
Additional Fetch options mode, cache, and redirect are now supported [@davidkna, #579]
The derive props macro now supports Properties with lifetimes [@jstarry, #580]
New ResizeService for registering for window size updates [@hgzimmerman, #577]
VNode orphaning bug when destroying VTag elements. This caused some Components to not be properly destroyed when they should have been. [@hgzimmerman, #651]where clause in derive_props macro [@astraw, #640]None
This release introduces a more developer friendly way to handle your Component props. Use the new #[derive(Properties)] macro to beef up your props! P
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.
html! - Self-closing html tags can now be used: <div class="marker" /> [@totorigolo, #523]html! - SVG name-spaced tags are now supported! [@jstarry, #550]<body> tag [@jstarry, @kellytk, #540]oninput events [@tiziano88, #549]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]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]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<()>,
}
() to specify state-related type parameters instead of the old macro-based solution. [157]JsSerializable bound on the state parameter used for storing extra data in the history API.[185]text prop. [192]default-features = false, you will have to now specify features = ["service"] to get the same behavior as before. [199]RouterAnchor and RouterButton now have props that take a route: SW where SW: Switch prop instead of a link: String and they now have a mandatory type parameter that specifies this SW. [207]Route's state field now holds a T instead of an Option<T>. [205]unit_state) means that any imports from that module should now be replaced with the path that the type normally has in the project. [157]T to STATE. [208]*Commas? We don't need no stinkin' commas!*
Commas? We don't need no stinkin' commas!
This release brings a new and improved html! macro for writing JSX-like syntax. Commas and colons are no longer necessary now that the macro is written as a procedural macro.
html! - Commas are no longer necessary for splitting up attributes [[@jstarry], #500]html! - Colons are no longer necessary for denoting a Component tag [[@jstarry], #500]<textarea value="content"> [[@DenisKolodin], #476]StorageService::restore to take an immutable receiver [[@dermetfan], #480]Clone in order to be used with the Router [171]One column per quarter.