Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

could not find yew in stylist

I’m new to rust and yew and trying to use stylist crate with yew but when I try to import styled_components, I am getting following error.

error[E0432]: unresolved import `stylist::yew`
 --> src\lib.rs:2:14
  |
2 | use stylist::yew::styled_component;
  |              ^^^ could not find `yew` in `stylist`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `hello-yew` due to previous error
2022-11-22T16:30:53.476368Z ERROR  error
error from HTML pipeline

Has anyone seen this issue before?

I tried to delete previous stylist crates and tried to re-install the crate again but faced same issue.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

From the docs:

Yew Integration

To enable yew integration. Enable feature yew_integration in Cargo.toml.

You can create a style and use it with yew like this:

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

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading