You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the code (putting the style! component within the view function of the class component produces the same error). This example is taken from the example page here (https://docs.rs/yew-style-in-rs/latest/yew_style_in_rs/)
use yew::prelude::*;
use yew_style_in_rs::*;
#[function_component]
pub fn Mdpages() -> Html {
style! {
let css = css! {r#"
border: solid green 1px;
width: 100%;
height: 150px;
text-align: center;
box-sizing: border-box;
& > p {
background: white;
}
"#};
}
html!{
<div class={classes!(css)}>
<p>{"compile time static css"}</p>
</div>
}
}
And here is the error -
error[E0277]: the trait bound `Classes: From<yew_style_in_rs::css::StyleId>` is not satisfied
--> src/pages/mdpages.rs:22:34
|
22 | <div class={classes!(css)}>
| ^^^ the trait `From<yew_style_in_rs::css::StyleId>` is not implemented for `Classes`
|
= help: the following other types implement trait `From<T>`:
<Classes as From<&'static str>>
<Classes as From<&Option<T>>>
<Classes as From<&String>>
<Classes as From<&[T]>>
<Classes as From<Cow<'static, str>>>
<Classes as From<Option<T>>>
<Classes as From<String>>
<Classes as From<Vec<T>>>
= note: required for `yew_style_in_rs::css::StyleId` to implement `Into<Classes>`
note: required by a bound in `Classes::push`
--> /Users/peterweyand/.cargo/registry/src/github.com-1ecc6299db9ec823/yew-0.20.0/src/html/classes.rs:58:20
|
58 | pub fn push<T: Into<Self>>(&mut self, class: T) {
| ^^^^^^^^^^ required by this bound in `Classes::push`
Some errors have detailed explanations: E0277, E0423.
For more information about an error, try `rustc --explain E0277`.
warning: `yew_page` (lib) generated 4 warnings
error: could not compile `yew_page` due to 2 previous errors; 4 warnings emitted
2023-02-05T03:08:40.774108Z ERROR ❌ error
error from HTML pipeline
Caused by:
0: error from asset pipeline
1: error during cargo build execution
2: cargo call returned a bad status
2023-02-05T03:08:40.774976Z INFO 📡 serving static assets at -> /
2023-02-05T03:08:40.775031Z INFO 📡 server listening at http://127.0.0.1:8080
This is as simple an example as I can make and I don't know why the error is occurring. I've found a workaround by including a hashmap of styles that I can import inside class components, but it's a bit clunky. Here is my Cargo.toml - maybe that's the issue, but I've imported yew_style_in_rs -
[package]
name = "yew_page"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
route = "0.2.0"
yew = { version = "0.20.0", features = ["csr"] }
yew-router = "0.17.0"
reqwest = "0.11.14"
wasm-logger = "0.2.0"
log = "0.4.17"
gloo-net = "0.2.5"
wasm-bindgen-futures = "0.4.33"
wasm-bindgen = "0.2.83"
js-sys = "0.3.60"
yew-style-in-rs = "0.4.1"
[dependencies.web-sys]
version = "0.3"
features = [
"Headers",
"Request",
"RequestInit",
"RequestMode",
"Response",
"Window",
'HtmlCanvasElement',
'WebGlBuffer',
'WebGlProgram',
'WebGlRenderingContext',
'WebGlShader',
'WebGlUniformLocation',
]
[[bin]]
name = "yew_page"
required-features = ["yew/csr"]
The text was updated successfully, but these errors were encountered:
This is due to yew_styles_in_rs does not support Yew v0.20. yew_styles_in_rs needs to be upgraded to support Yew v0.20 or you need to use Yew v0.19 with yew_styles_in_rs.
Here is the code (putting the
style!
component within the view function of the class component produces the same error). This example is taken from the example page here (https://docs.rs/yew-style-in-rs/latest/yew_style_in_rs/)And here is the error -
This is as simple an example as I can make and I don't know why the error is occurring. I've found a workaround by including a hashmap of styles that I can import inside class components, but it's a bit clunky. Here is my
Cargo.toml
- maybe that's the issue, but I've importedyew_style_in_rs
-The text was updated successfully, but these errors were encountered: