Using <For>
with Signal<Vec<Item>>
#1605
Unanswered
bryanmylee
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Sure: the two options would either be
struct Message {
id: usize,
text: RwSignal<String>,
} This allows you to make fine-grained updates to
view! { cx,
<For
each=messages
key=|m| m().id
view=move |cx, message| {
// this may be a little off but hopefully you get the idea
let contents = create_memo(cx, move |_| {
messages.with(|m| m.iter().find(|msg| msg.id = message.id).map(|m| m.text).unwrap_or_default());
});
<li>{contents}</li>
}
/>
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm experimenting with Leptos and really liking it so far. However, one thing that confuses me is how I'm supposed to implement fine-grained reactivity with iteration.
I've created a signal for some data:
I'm then passing the data into a for loop:
However, because the individual items aren't signals, my
<li>
items aren't reactive.I've tried deriving signals for each item in my
data
, but it's not working and I'm not experienced enough to understand it.Is there a generally accepted solution for this behavior?
Beta Was this translation helpful? Give feedback.
All reactions