ranile / material-yew

Yew wrapper for Material Web Components
https://material-yew.rm.rs
Apache License 2.0
230 stars 35 forks source link

FYI: Up and coming Yew version will introduce breaking changes #31

Closed DevinLeamy closed 1 year ago

DevinLeamy commented 2 years ago

The next version of Yew will be introducing the BaseComponent, which will function to replace the existing Component trait. Consequently, existing components will not be able to be used in html! { ... }.

This can be demonstrated by using yew = { git = "https://github.com/yewstack/yew.git", features = ["csr"] } and trying

html! {
    <MatButton label="My Button" />
}

Docs for the new version: https://api.yew.rs/next/yew/prelude/trait.BaseComponent.html

p.s. This component library is exactly what I'm looking for! Thanks for building it!

DevinLeamy commented 2 years ago

This can be temporarily fixed with this patch in lib.rs

// https://stackoverflow.com/questions/23975391/how-to-convert-a-string-into-a-static-str
fn string_to_static_str(s: String) -> &'static str {
    Box::leak(s.into_boxed_str())
}

fn to_option_string(s: impl Display) -> Option<AttrValue> {
    let s = s.to_string();
    if s.is_empty() {
        None
    } else {
        Some(AttrValue::Static(string_to_static_str(s))) // <--- Problematic line
    }
}
ranile commented 1 year ago

Closing this as the library has been updated to next Yew version.