-
hi, // let (_, write_theme, _) = use_local_storage::<String, FromToStringCodec>("theme");
let change_theme = {
// let mut mode_dark = dark_mode.clone();
if theme_name.get_untracked() == "Light" {
theme.set(Theme::light());
// write_theme.set("light".to_string());
// mode_dark.set_light();
} else {
theme.set(Theme::dark());
// write_theme.set("dark".to_string());
// mode_dark.set_dark();
}
}; source code: https://github.com/bendo01/xsia_leptos_ui_csr_v1_public/blob/main/src/app.rs it give me an error because i'm combining mutable variable in clojure, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
When I try to compile your repo, I get this error
This says, This is because instead of making Change this: let change_theme = {
let mut mode_dark = dark_mode.clone();
if theme_name.get_untracked() == "Light" {
theme.set(Theme::light());
// write_theme.set("light".to_string());
mode_dark.set_light();
} else {
theme.set(Theme::dark());
// write_theme.set("dark".to_string());
mode_dark.set_dark();
}
}; to this let change_theme = move |_| {
let mut mode_dark = dark_mode.clone();
if theme_name.get_untracked() == "Light" {
theme.set(Theme::light());
// write_theme.set("light".to_string());
mode_dark.set_light();
} else {
theme.set(Theme::dark());
// write_theme.set("dark".to_string());
mode_dark.set_dark();
}
}; and it compiles fine. (This doesn't have anything to do with mixing mutable and immutable variables or anything -- it's essentially just a typo or syntax error, you've assigned a block that doesn't return anything instead of assigning a function to the variable) |
Beta Was this translation helpful? Give feedback.
When I try to compile your repo, I get this error