From 1a55b45d01fa4af2ef51eaaa713c4998f15e1c98 Mon Sep 17 00:00:00 2001 From: luoxiaozero <48741584+luoxiaozero@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:17:25 +0800 Subject: [PATCH] fix: Icon returns the function's warning (#127) --- thaw/src/icon/mod.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/thaw/src/icon/mod.rs b/thaw/src/icon/mod.rs index 80a75ad..a09b372 100644 --- a/thaw/src/icon/mod.rs +++ b/thaw/src/icon/mod.rs @@ -38,9 +38,9 @@ pub fn Icon( let icon = icon.get(); let style = match (style.clone(), icon.style) { - (Some(a), Some(b)) => Some((move || format!("{b} {}", a.get())).into_attribute()), - (Some(a), None) => Some((move || a.get()).into_attribute()), - (None, Some(b)) => Some(b.into_attribute()), + (Some(a), Some(b)) => Some(Memo::new(move |_| format!("{b} {}", a.get())).into()), + (Some(a), None) => Some(a), + (None, Some(b)) => Some(b.into()), (None, None) => None, }; icon_style.set(style); @@ -49,14 +49,14 @@ pub fn Icon( icon_y.set(icon.y.map(|y| y.into_attribute())); let width = match (width.clone(), icon.width) { - (Some(a), _) => (move || a.get()).into_attribute(), - _ => "1em".into_attribute(), + (Some(a), _) => a, + _ => "1em".into(), }; icon_width.set(Some(width)); let height = match (height.clone(), icon.height) { - (Some(a), _) => (move || a.get()).into_attribute(), - _ => "1em".into_attribute(), + (Some(a), _) => a, + _ => "1em".into(), }; icon_height.set(Some(height)); @@ -72,11 +72,11 @@ pub fn Icon( view! { >>) -> Option { + signal.with(|s| match s { + Some(MaybeSignal::Static(value)) => Some(value.clone()), + Some(MaybeSignal::Dynamic(signal)) => Some(signal.get()), + _ => None, + }) +} + fn take(signal: RwSignal>) -> Option { signal.track(); signal.try_update_untracked(|value| value.take()).flatten()