-
- Attempt to fix recursion on display. [@mibes, #2149]
- Fix default passive option. [@mc1098, #2111]
- Fix trybuild. [@mc1098, #2103]
- Fix event handler during capture phase. [@mc1098, #2062]
- Fix
VTag
reuse to reset ancestorNodeRef
. [@mc1098, #2030] - Fix IntoEventCallback over IntoPropValue. [@mc1098, #2025]
- Remove underscore prefix on fn parameters. [@mc1098, #2010]
- Fix rust-analyzer #[derive(Properties)] warnings. [@KarlitosVII, #2007]
- Fix clippy lints from 1.54.0. [@Xavientois, #1976]
- Fix scheduler main queue delay (#1953). [@intendednull, #1954]
- Fix case warning on derived properties. [@nitnelave, #1929]
- yew-macro: fix inability to set the autoplay atribute. [@bakape, #1866]
- Fix duplicate
with props
error messages.. [@teymour-aldridge, #1730] - Remove extra braces in html_nested macro. [@Madoshakalaka, #2169]
- Remove unused punct field from props. [@Xavientois, #1969]
-
- Check event bubbling cancellation at each step of propagation. [@rjmac, #2191]
- Add possibility to cancel bubbling. [@voidpumpkin, #2172]
- Add the ability to add child nodes conditionally in
html!
. [@cecton, #1609] - Add basic lints to the HTML macro.. [@teymour-aldridge, #1748]
- Refactor use ref hooks. [@mc1098, #2093]
- Implementation of portals. [@WorldSEnder, #2147]
- Allow Classes properties to be created from string literals. [@jplatte, #2141]
- Use functions from
gloo_utils
instead of re-implementing them. [@hamza1311, #2124] - Reliable
use_reducer
dispatch anduse_state
setter. [@futursolo, #2126] - Add custom type for attribute values. [@hamza1311, #1994]
- Remove trailing semicolon in macro used in expression position. [@vrmiguel, #2127]
- Add set_if_neq for UseStateHandle. [@voidpumpkin, #2109]
- Add safe first_node fn. [@mc1098, #2094]
- impl PartialEq for
UseStateHandle
andUseReducerHandle
. [@hamza1311, #2092] - Remove
web_sys
re-export. [@mc1098, #2084] - Use into_prop_value to convert str prop to Option. [@Xavientois, #2080]
- Component lifecycle scheduler optimizations. [@bakape, #2065]
- Update dependencies. [@mc1098, #2064]
- Add support for missing boolean attributes. [@mc1098, #2051]
- Add fully qualified primitives in proc macro. [@mc1098, #2037]
- Remove 'static lifetime from hook init function. [@mc1098, #2039]
- Add "struct update" syntax to pass props to component (
..props
instead ofwith props
). [@Xavientois, #2024] - Add
no_implicit_prelude
to proc macro tests. [@mc1098, #2033] - Dev/listener multiplexer. [@bakape, #1542]
- Remove ShouldRender type alias. [@mc1098, #2011]
- Components v2 (2). [@hamza1311, #1961]
- Remove InputData & ChangeData. [@mc1098, #2000]
- Support const generics in
#[derive(Properties)]
. [@maciejhirsz, #1978] - Add shorthand syntax for props. [@Xavientois, #1970]
- Static attribute lists. [@bakape, #1962]
- yew/vlist: optimize diffing and patching. [@bakape, #1555]
- Add requirement for braces around most props. [@Xavientois, #1939]
- Optimize VTag construction, memory footprint and patching. [@bakape, #1947]
- Refactor and cleanup codebase. [@hamza1311, #1842]
- Helper to build changelog. [@cecton, #1845]
- Implicit optional attributes. [@siku2, #1637]
- yew: reduce scheduler call indirection. [@bakape, #1903]
- Change match statement to if. [@Xavientois, #1884]
- Optimize vtag construction. [@bakape, #1867]
- Apply Clippy lints.. [@teymour-aldridge, #1863]
- Change the app struct to be a real handle to an Yew app instance and make it possible to destroy a running app. [@nicklaswj, #1825]
- Bring context to standard components. [@Diggsey, #1835]
- Upgraded Hook API (2). [@hamza1311, #1780]
- Store hook state in a mutable scoped-TLS. [@Diggsey, #1831]
- Remove unnecessary allocation from
AnyScope
. [@Diggsey, #1830] - Added missing licenses to Cargo.toml files and updated to use SPDX syntax. [@jbg, #1822]
- Update Rust version for macro tests to 1.51 & enable const generics tests. [@hamza1311, #1801]
- Allow the use of Rust keywords for element names. [@siku2, #1772]
- Refactor html tag peeking. [@lukechu10, #1738]
- Generic functional components. [@lukechu10, #1756]
- Add support for the unit struct in Properties derive. [@Xavientois, #1752]
- Rip out stdweb. [@philip-peterson, #1697]
-
- Fix Some Router Behaviour. [@futursolo, #2107]
- Fix multiple field enum tokens. [@mc1098, #1988]
- Fix clippy lints from 1.54.0. [@Xavientois, #1976]
- Fix router. [@hamza1311, #1856]
- update nom 6.1.2 and fix compile errors.. [@higumachan, #1806]
-
- Add missing router docs: Redirect, Nested Router, and Path Segament capturing. [@Madoshakalaka, #2192]
- use base url for href of links. [@WorldSEnder, #2177]
- Use functions from
gloo_utils
instead of re-implementing them. [@hamza1311, #2124] - Update Yew Router as per #2113. [@futursolo, #2118]
- Update dependencies. [@mc1098, #2064]
- Add "replace route" call as a companion to "push route". [@rjmac, #2023]
- Add shorthand syntax for props. [@Xavientois, #1970]
- Add requirement for braces around most props. [@Xavientois, #1939]
- Clean-up and optimize router a little bit. [@hamza1311, #1869]
- Apply Clippy lints.. [@teymour-aldridge, #1863]
- Rewrite router. [@hamza1311, #1791]
- Added missing licenses to Cargo.toml files and updated to use SPDX syntax. [@jbg, #1822]
- Update Rust version for macro tests to 1.51 & enable const generics tests. [@hamza1311, #1801]
- Add support for the unit struct in Properties derive. [@Xavientois, #1752]
-
- Fix unmaintained anymap dependency. [@mc1098, #2071]
- Fix clippy lints from 1.54.0. [@Xavientois, #1976]
- Fix crash in link to destroyed agents. [@kristoff3r, #1827]
-
- allow web worker resource to be relative. [@astraw, #2086]
use_bridge
hook for agents. [@futursolo, #2125]- Use functions from
gloo_utils
instead of re-implementing them. [@hamza1311, #2124] - yew-agent: add missing web-sys features. [@astraw, #2085]
- Update dependencies. [@mc1098, #2064]
- Drop Private worker handler when bridge is dropped. [@FrancisMurillo, #1944]
-
- Implicit optional attributes. [@siku2, #1637]
- Added callback_future_once in yewtil.(#1712). [@fraillt, #1696]
- Added relevant examples section to the docs. [@oOBoomberOo, #1695]
- Added missing KeyboardService re-export. [@SOF3, #1694]
- Rename internal Agent structs to match Component. [@jstarry, #1688]
- Add discussion link to issue selector. [@jstarry, #1674]
- Update link to Material Design Components. [@TapioT, #1662]
- Extract Classes to a separate macro. [@cecton, #1601]
- Improve the "keyed_list" example. [@titaneric, #1650]
- Add documentation for component children. [@K4rakara, #1616]
- Add a macro for building properties outside of html!. [@siku2, #1599]
-
- None
-
- None
-
RouterButton
now prevents default events per default @TheNeikos
-
- Added
prompt
function toDialogService
. [@teymour-aldridge, #1350] - Implement
From<&[T]>
whereT: AsRef<str>
forClasses
. [@alexschrod, #1448] - Added
batch_callback_once
toComponentLink
. [@ctron, #1463]
- Added
-
Key
now implementsDeref<Target = str>
. [@faulesocke, #1370]
-
- None
-
- None
-
- The
unit_state
module has been removed. - Bump
yew
version to0.17
.
- The
-
-
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 forVChild
when properties also implementPartialEq
. [[@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
andref
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 tohtml! { node_list }
whennode_list
is aVec<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
andOutput
to implementSerializable
. [@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
, andWebSocketService
methods are now static. [@teymour-aldridge, #1313] -
html!
:Children
no longer implementsRenderable
. [@siku2, #1275]Replace instances of
self.props.children.render()
withself.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 usesFocusEvent
insteadEvent
when usingweb-sys
. [@siku2, #1244] -
The
onmousewheel
andontouchenter
listeners have been removed. [@siku2, #1244] -
The
ondoubleclick
listener is now namedondblclick
. [@siku2, #1244] -
FetchService
methods are now static. [@teymour-aldridge, #1235]Instead of
FetchService::new().fetch(..)
you should now useFetchService::fetch(..)
-
The
send_message_batch
method has been removed fromAgentLink
. [@totorigolo, #1215] -
Minimum supported rust version has been bumped from
1.40.0
to1.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]
-
-
- Bump
yew
version to0.16
.
- Bump
-
-
Added optional
id
,class
, andplaceholder
properties to theSelect
component. [@Stigjb, #1187] -
Re-export
web-sys
from Yew. This allows projects to useweb-sys
without adding it to theirCargo.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
andget_component
methods toComponentLink
to allow access to parent component state. [@jstarry, #1151]
-
-
- Fixed bug that caused html class attributes to be set to an empty string. [@liquidblock, #1085]
- Fixed
Private
worker lifecycle event sending. [@joaquindk, #1146]
-
- Fix infinite rerender bug in 'Router' component. (Thanks @dancespiele)
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
-
- Split class names on whitespace when passed within
tuple
orVec
. [@bryanjswift, #1084]
- Split class names on whitespace when passed within
-
- The
components
module has been moved outyew
and intoyew-components
. [@jstarry, #1132] - Replaced
mounted
component lifecycle method withrendered
which is called after each render. [@jstarry, #1072] - Components must now implement the
change
method (forgetting this was a very common issue). [@jstarry, #1071] - Yew now builds with
web-sys
by default. [@jstarry, #1092]
- The
-
- Bump
yew
version to0.15
.
- Bump
-
- Remove
guide
example.
- Remove
-
- Remove
html!
component validation to allow generic components. [@mankinskin, #1065] - Improve
Debug
formatting forVTag
andVText
. [@dancespiele, #1059] - Implement
Default
forCallback
. [@TheNeikos, #1043]
- Remove
-
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 diving into the migration from stdweb
to web-sys
so quickly and uncovering these issues!
-
- Implemented
Clone
forWebSocketStatus
. [@kellytk, #1023] - Improved ergonomics for message APIs by accepting
Into<Msg>
. [@captain-yossarian, #999] html!
improved compiler messages and flexible syntax forwith props
. [@captain-yossarian, #960]
- Implemented
-
- Fixed panic in
stdweb
ResizeService
event handling. [@nicklaswj, #1014] - Removed build check for OS compatibility. [@jstarry, #1019]
- Fixed interval and timer usage in
web-sys
workers by updatinggloo
. [@jstarry, #1018] - Send
Connected
message for Public agents. [@TheNeikos, #1007] - Fixed
web-sys
Public / Private agent initialization. [@jstarry, #1006] - Fixed websocket 'text' message handling for
web-sys
agents. [@jstarry, #1005]
- Fixed panic in
-
FetchError::FetchFailed
enum variant now wraps aString
to hold the failure reason. [@jstarry, #1025]- Message APIs now accept
Into<Msg>
, so callingmsg.into()
will cause compile errors. [@captain-yossarian, #999]
- Bumped version of Yew from v0.12.0 to v0.13.0
- This brings support for web_sys, which necessitates specifying either "web_sys" or "std_web" as a feature. (Thanks @tarkah)
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!
-
-
- Fixed
Component
children re-rendering bug. [@jstarry, #980] - Fixed panic when interacting with agents after receiving an agent message. [@jstarry, #981]
- Fixed panic when a component with a root
VRef
node is detached. [@jstarry, #983] - Fixed annoying warning when a component with a root
VTag
node is detached. [@jstarry, #983]
- Fixed
-
- Changed
Properties
macro behavior. Check out the proposal issue #928 for more details! [@AlephAlpha, #975] - Cleaned up exported apis and doc visibility. [@jstarry, #977]
ReaderService
methods now return aResult
instead of panicking. [@daxpedda, #868]FetchService
methods now return aResult
instead of panicking. [@daxpedda, #867]StorageService
methods now return aResult
instead of panicking. [@daxpedda, #827]
- Changed
-
- Improved error handling in macro. [233] @jplatte
-
- Improved ergonomics for
html! { for .. }
. [@jstarry, #875] - Added
#[props(default = "fn_path")]
for specifying a default property value. [@AlephAlpha, #881] - Exposed the macros for creating format types. [@ctm, #883]
- Added support for binary-only and text-only formats in
WebSocketService
. [@ctm, #851] - Implemented
PartialEq
forChildrenRenderer
to allowchildren
comparison. [@jstarry, #916] - Reduced restrictions on
ComponentLink
methods to improveFuture
support. [@jplatte, #931] - Added
referrer
,referrer_policy
andintegrity
toFetchOptions
. [@leo-lb, #931]
- Improved ergonomics for
-
- Fixed a dependency issue with
wasm-bindgen
that would cause builds to fail when building for thewasm32-unknown-unknown
target.
- Fixed a dependency issue with
-
- Use a default type parameter of
()
to specify state-related type parameters instead of the old macro-based solution. [157] - Remove need for
JsSerializable
bound on the state parameter used for storing extra data in the history API.[185] - RouterLink and RouterButton now support having children Html. This deprecates the
text
prop. [192] - Fragment routing is now easily implementable by using an adapter because parser rules for the routing syntax were relaxed. [195] [211]
- Support using this library only with the Switch derive, allowing it to run in non-web contexts. [199]
- Use a default type parameter of
-
- If you were using
default-features = false
, you will have to now specifyfeatures = ["service"]
to get the same behavior as before. [199] RouterAnchor
andRouterButton
now have props that take aroute: SW where SW: Switch
prop instead of alink: String
and they now have a mandatory type parameter that specifies thisSW
. [207]Route
's state field now holds aT
instead of anOption<T>
. [205]- Using default type parameters to specify the state typ instead of the macro that generated a module (
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]
- If you were using
-
- Change state related type parameters from
T
toSTATE
. [208]
- Change state related type parameters from
This release aims to lay the groundwork for Yew component libraries and 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 MyComponent;
enum Msg {
Click,
}
impl Component for MyComponent {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
MyComponent
}
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 MyComponent {
link: ComponentLink<Self>,
}
enum Msg {
Click,
}
impl Component for MyComponent {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
MyComponent { 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
->AgentLifecycleEvent
These renames will probably require some more care:
fn handle(
->fn handle_input(
(for Agent trait implementations)
🎉 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 MyComponent {
// ...
fn view(&self) -> Html<Self> {
html! { /* ... */ }
}
}
After:
impl Component for MyComponent {
// ...
fn view(&self) -> Html {
html! { /* ... */ }
}
}
In 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.
-
- Added
html_nested!
macro to support nested iterable children access. [@trivigy, #843] - Added
bincode
to the list of supported formats. [@serzhiio, #806] - Added a
noop()
convenience method toCallback
which creates a no-op callback. [@mdtusz, #793] - The
html!
macro now accepts aCallback
for element listeners. [@jstarry, #777]
struct MyComponent { onclick: Callback<ClickEvent>, } enum Msg { Click, } impl Component for MyComponent { type Message = Msg; type Properties = (); fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self { MyComponent { 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> } } }
- Add
send_message_batch
method toComponentLink
. [@hgzimmerman, #748] - Allow compilation to
wasi
target withoutwasm_bindgen
. [@dunnock, #746] AgentLink
now implementsClone
which enablesFuture
usage without explicit Yew framework support. [@izissise, #802]ComponentLink
now implementsClone
which enablesFuture
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);
- Added
-
- Fixed handling of boolean tag attributes. [@mrh0057, #840]
- Improved nested component ergonomics. [@jstarry, #780]
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> } }
- Creating a
Callback
withComponentLink
is no longer restricted to mutable references, improving ergonomics. [@jstarry, #780] - The
Callback
reform
method no longer consumes self making it easier to "reverse map" aCallback
. [@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> } } }
- Reduced allocations in the
Classes
to_string
method. [@hgzimmerman, #772] - Empty string class names are now filtered out to prevent panics. [@jstarry, #770]
-
- Components with generic args now need to be closed with the full type path. (e.g.
html! { <Wrapper<String>></Wrapper<String>>}
) [@jstarry, #837] - Changed
VTag
listener type fromBox<dyn Listener>
toRc<dyn Listener>
. [@jstarry, #786] Properties
need to implementClone
again in order to improve nested component ergonomics. [@jstarry, #786]- Removed
send_future
method fromComponentLink
since it is no longer necessary for using Futures with Yew. [@hgzimmerman, #799] - Removed generic type parameter from
Html
and all virtual node types:VNode
,VComp
,VTag
,VList
,VText
, etc. [@jstarry, #783] - Removed support for macro magic closure syntax for element listeners. (See transition guide for how to pass a
Callback
explicitly instead). [@jstarry, #782] - Renamed
Agent
methods and event type for clarity.handle
->handle_input
,AgentUpdate
->AgentLifecycleEvent
,response
->respond
. [@philip-peterson, #751] - The
ComponentLink
send_back
method has been renamed tocallback
for clarity. [@jstarry, #780] - The
ComponentLink
send_self
andsend_self_batch
methods have been renamed tosend_message
andsend_message_batch
for clarity. [@jstarry, #780] - The
Agent
send_back
method has been renamed tocallback
for clarity. [@jstarry, #780] - The
VTag
children
value type has changed fromVec<VNode>
toVList
. [@jstarry, #754]
- Components with generic args now need to be closed with the full type path. (e.g.
-
Future
support 🎉 AComponent
can update following the completion of aFuture
. Check out this example to see how it works. This approach was borrowed from a fork of Yew calledplaster
created by @carlosdp. [@hgzimmerman, #717]- Added the
agent
andservices
features so that this functionality can be disabled (useful if you are switching to usingFuture
s). [@hgzimmerman, #684] - Add
ref
keyword for allowing aComponent
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::prelude::*; 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" /> } } }
- Make
Agent
related typespublic
to allow other crates to create custom agents. [@dunnock, #721] Component::change
will now returnfalse
for components that haveComponent::Properties == ()
. [@kellytk, #690]]- Updated
wasm-bindgen
dependency to0.2.54
. Please update yourwasm-bindgen-cli
tool by runningcargo install --force --version 0.2.54 -- wasm-bindgen-cli
. [@jstarry, #730], [@ctaggart, #681]
-
- Fixed the mount order of components. The root component will be mounted after all descendants have been mounted. [@jstarry, #725]
- All public items now implement
Debug
. [@hgzimmerman, #673]
-
-
Minimum rustc version has been bumped to
1.39.0
forFuture
support. [@jstarry, #730] -
Component
now has a requiredview
method and automatically implements theRenderable
trait. Theview
method in theRenderable
trait has been renamed torender
. [@jstarry, #563]Before:
impl Component for MyComponent { type Message = Msg; type Properties = (); fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self { MyComponent {} } fn update(&mut self, msg: Self::Message) -> ShouldRender { true } } impl Renderable<MyComponent> for MyComponent { fn view(&self) -> Html<Self> { html! { "hello" } } }
After:
impl Component for MyComponent { type Message = Msg; type Properties = (); fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self { MyComponent {} } 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 serdeSerialize
andDeserialize
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 aResult
in order to stop panicking on malformed urls. [@lizhaoxian, #727] -
VTag
now is boxed withinVNode
to shrink the size of its enum representation. [@hgzimmerman, #675]
-
-
- Upgrade to Yew 0.10.0
- Switch components now need to implement
Clone
in order to be used with theRouter
[171]
-
- Bring back
{}
,{*}
, and{<number>}
capture syntax for tuple structs/enum variants. If your variant or struct doesn't have named fields, you don't need to supply names in the matcher string [116] - Allow ! special character in more places.
- Greatly improve the quality of matcher string parsing errors. [171]
- Add
impl<SW: Switch, T> From<SW> for Route<T>
. Now Routes can be created from Switches easily. - Allow escaping {, }, and ! special characters by using
{{
,}}
, and!!
respectively. - Provide a correct error message when attempting to derive
Switch
for a Unit struct/variant with a capture group.
- Bring back
-
Switch
trait and Proc Macro enables extracting data from route strings.Router
component added.RouterLink
andRouterButton
helper components added.
-
- Nearly everything. Most items were renamed.
- Upgrade to Yew 0.9.0
-
- Fix
yew-macro
dependency version
- Fix
Happy Canadian Thanksgiving! 🦃
-
- Implemented
Default
trait forVNode
so thatunwrap_or_default
can be called onOption<Html<Self>>
. [@hgzimmerman, #672] - Implemented
PartialEq
trait forClasses
so that is more ergonomic to useClasses
type in component props. [@hgzimmerman, #680] - Updated
wasm-bindgen
dependency to0.2.50
. Please update yourwasm-bindgen-cli
tool by runningcargo install --force --version 0.2.50 -- wasm-bindgen-cli
. [@jstarry, #695]
- Implemented
-
- Fixed issue where text nodes were sometimes rendered out of order. [@jstarry, #697]
- Fixed regression introduced in 0.9.0 that prevented tag attributes from updating properly. [@jstarry, #698]
- Fixed emscripten builds by pinning the version for the
ryu
downstream dependency. [@jstarry, #703] - Updated
stdweb
to0.4.20
which fixed emscripten builds and unblocked updatingwasm-bindgen
to0.2.50
. [@ctaggart, @jstarry, #683, #694] - Cleaned up build warnings for missing
dyn
keywords. [[@benreyn], #687]
-
-
New
KeyboardService
for setting up key listeners on browsers which support the feature. [@hgzimmerman, #647] -
ComponentLink
can now create aCallback
with more than oneMessage
. TheMessage
's will be batched together so that theComponent
will not be re-rendered more than necessary. [@stkevintan, #660] -
Message
's toPublic
Agent
's will now be queued if theAgent
hasn't finished setting up yet. [@serzhiio, #596] -
Agent
's can now be connected to without aCallback
. Instead of creating a bridge to the agent, create a dispatcher like so:MyAgent::dispatcher()
. [@hgzimmerman, #639] -
Component
's can now accept children in thehtml!
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>>() }} } }
-
Iterator
s can now be rendered in thehtml!
macro without using thefor
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 anmounted
method which can be implemented to react to when your components have been mounted to the DOM. [@hgzimmerman, #583] -
Additional Fetch options
mode
,cache
, andredirect
are now supported [@davidkna, #579] -
The derive props macro now supports Properties with lifetimes [@jstarry, #580]
-
New
ResizeService
for registering forwindow
size updates [@hgzimmerman, #577]
-
-
- Fixed JS typo in RenderService. This was causing animation frames to not be dropped correctly. [@jstarry, #658]
- Fixed
VNode
orphaning bug when destroyingVTag
elements. This caused someComponent
s to not be properly destroyed when they should have been. [@hgzimmerman, #651] - Fix mishandling of Properties
where
clause in derive_props macro [@astraw, #640]
-
None
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]- 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]
-
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]
-
-
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<()>, }
-
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!{}
is now valid syntax and can be used to render nothing [@jstarry, #500]- Apps can now be built without
cargo-web
usingwasm-bindgen
[@jstarry, #497] Callback
now implementsDebug
[@DenisKolodin, #485]- New utility method for getting the
host
of the current page [@DenisKolodin, #509]
-
html!
- Commas are no longer necessary for splitting up attributes [@jstarry, #500]html!
- Colons are no longer necessary for denoting aComponent
tag [@jstarry, #500]- Textarea value can be now be set:
<textarea value="content">
[@DenisKolodin, #476] - changed
StorageService::restore
to take an immutable receiver [@dermetfan, #480] - Fixed a component rendering bug [@jstarry, #502]
-
- Added
start_app
convenience method for initializing the app and mounting it to the body [@DenisKolodin, #462] - Added handling of files of
input
element. There is now aChangeData::Files
variant for theonchange
handler [@DenisKolodin, #464] - Added
ReaderService
to read data fromFile
instances. [@DenisKolodin, #464, #468]
- Added
-
- It was impossible to set
value
attribute for any tag instead ofoption
, because it used inner value ofVTag
to keep the value forinput
element. Nowvalue
attribute works foroptions
,progress
tags, etc.
- It was impossible to set
-
- New example
file_upload
that prints sizes of uploaded files [@DenisKolodin, #464]
- New example
🎶 Secret Agent Man 🎶
This release introduces the concept of an Agent
. Agents are separate activities which you could run in the same thread or in a separate thread. There are three types of agents Context
, Job
, Public
described below. To connect to an agent use the Worker::bridge
method and pass a link of component's environment to it.
-
- Introduced the concept of an
Agent
which can run processes in other contexts:Context
agent spawns once per threadJob
agent spawns for every bridgePublic
agent spawns an agent in a separate thread (it uses Web Workers API under the hood).
- Allow setting the whole properties struct of a component with
<Component: with props />
ComponentLink
now has asend_self
method which allows components to update themselves [@DenisKolodin, #365]- All services are re-exported within the
yew::services
module. html!
macro supports multiple classes in a single string:<a class="button is-primary",>
.- Added
FetchOptions
to allow settingCredentials
offetch
request. FetchService
aborts requests usingAbortController
.- Added
SubmitEvent
withonsubmit
rule.
- Introduced the concept of an
-
- Bug with emscripten target
RuntimeError: index out of bounds
fixed with a new scheduler [@DenisKolodin, #272]
- Bug with emscripten target
-
send_back
method requires a mutable reference toself
. This was added to prevent creating callbacks inview
implementations. [@DenisKolodin, #367]Context
requirement removed. It's no longer necessary to useComponent<CTX>
type parameter. Instead, a link to the environment is provided with theComponent::create
call. [@DenisKolodin, #272]