futursolo / stylist-rs

A CSS-in-Rust styling solution for WebAssembly Applications
https://crates.io/crates/stylist
MIT License
366 stars 22 forks source link

Could not find styled_component #103

Closed hanusek closed 1 year ago

hanusek commented 1 year ago

Hello @futursolo I have a weird problem.

Cargo.toml:

stylist = {verion = "0.11.0", features = ["yew_integration"]}
yew = "0.19.3"

main.rs

use stylist::yew::styled_component;
use yew::prelude::*;

#[styled_component]
fn MyStyledComponent() -> Html {
    html! {<div class={css!("color: red;")}>{"Hello World!"}</div>}
}

log:

error: unexpected end of input, expected identifier for the component
   --> web-gui/src/main.rs:214:1
    |
214 | #[styled_component]
WorldSEnder commented 1 year ago

stylist ="0.11" is only meant to be used with yew = "0.20", if you are stuck with yew 0.19, perhaps you can downgrade to stylist 0.10? In that case, you need to use a bit more verbose syntax here:

use stylist::yew::styled_component;
use yew::prelude::*;

#[styled_component(MyStyledComponent)]
fn my_styled_component() -> Html {
    html! {<div class={css!("color: red;")}>{"Hello World!"}</div>}
}

Feel free to reopen if this still doesn't work after upgrading to yew 0.20