ranile / material-yew

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

cant use MatButton ? #37

Closed nash1111 closed 1 year ago

nash1111 commented 1 year ago

I want to do what is stated in the README, render MatButton

src/main.rs

use yew::prelude::*;
use yew::html;
use material_yew::MatButton;

#[function_component]
fn HelloWorld() -> Html {
    html! {<MatButton label="Click me!" />}
}

#[function_component(App)]
fn app() -> Html {
    html! {
        <>
        <h1>{ "Hello World" }</h1>
        <HelloWorld />
        </>
    }
}

fn main() {
    yew::Renderer::<App>::new().render();
}

Cargo.toml

[dependencies]
yew = { version = "0.20", features = ["csr"] }
material-yew = { version = "0.1.0", features = ["full"] }

But I get the following error. How can I fix it? I'm new to yew and don't know if this is a bug, I'm asking in QA. Thanks in advance

error[E0277]: the trait bound `MatButton: yew::Component` is not satisfied
 --> src/main.rs:7:13
  |
7 |     html! {<MatButton label="Click me!" />}
  |             ^^^^^^^^^ the trait `yew::Component` is not implemented for `MatButton`
  |
  = help: the trait `yew::Component` is implemented for `ContextProvider<T>`
  = note: required for `MatButton` to implement `yew::BaseComponent`
  = note: this error originates in the macro `html` (in Nightly builds, run with -Z macro-backtrace for more info)
ootoo1 commented 1 year ago

material-yew doesn't support yew 0.20.0 yet. I created a fork of material-yew which is updated to yew 0.20.0, so if you change your Cargo.toml to the following it compiles.

[package]
name = "clickme"
version = "0.1.0"
edition = "2021"

[dependencies]
yew = { version = "0.20.0", features = ["csr"]}
material-yew = { git = "https://github.com/ootoo1/material-yew.git", features = ["full"]}
nash1111 commented 1 year ago

It works, thanks!