The conditional rendering of <svg>
is incorrect
#3971
-
I have a simple personal blog in Leptos, and I'd like to call for help. Today, I tried to upgrade the dependencies:
I also upgraded the And then I found the theme_switcher is broken. (It's at the top-right corner of the page.) The relevant components are: I tried to print some logs in the UI: // @file theme_switcher
{move || {
match theme.get() {
Theme::Dark => {
leptos::logging::log!("{:?}", theme.get()); // print theme
view! { <MoonIcon /> }.into_any()
},
Theme::Light => {
leptos::logging::log!("{:?}", theme.get()); // print theme
view! { <SunIcon /> }.into_any()
},
Theme::Unknown => {
view! {
<span class="block invisible text-0 size-6">
"Theme Unknown"
</span>
}
.into_any()
}
}
}}
// @file moon_icon
#[component]
pub fn MoonIcon() -> impl IntoView {
leptos::logging::log!("Rendering MoonIcon");
view! {
// SVG...
}
}
// @file sun_icon
#[component]
pub fn SunIcon() -> impl IntoView {
leptos::logging::log!("Rendering SunIcon");
view! {
// SVG...
}
} I found after I toggled the theme to I also try to replace the Theme::Dark => {
view! { "M" }.into_any()
},
Theme::Light => {
view! { "S" }.into_any()
}, And it works well. I'd like to know what's the difference between conditional rendering svg and text. Thanks for your attention and your patience. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you think it's a bug, it would be helpful if you open an issue with a minimal reproduction (not your whole site) that fixes can be tested against. |
Beta Was this translation helpful? Give feedback.
If you think it's a bug, it would be helpful if you open an issue with a minimal reproduction (not your whole site) that fixes can be tested against.