fix(item list): make item list reactive.
This commit is contained in:
parent
4137ded856
commit
d9b60fb9f1
|
@ -28,7 +28,7 @@ pub fn App() -> impl IntoView {
|
|||
// Form component for adding new items.
|
||||
<ItemForm on_submit=Box::new(add_item) />
|
||||
// Component to display the list of items.
|
||||
<ItemsList items=items_signal.get() />
|
||||
<ItemsList items=items_signal />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ use leptos::*;
|
|||
use crate::models::item::Item;
|
||||
|
||||
#[component]
|
||||
pub fn ItemsList(items: Vec<Item>) -> impl IntoView {
|
||||
pub fn ItemsList(items: ReadSignal<Vec<Item>>) -> impl IntoView {
|
||||
view! {
|
||||
<div>
|
||||
<h2>{ "Items" }</h2>
|
||||
<ul>
|
||||
{items.iter().enumerate().map(|(i, item)| view! {
|
||||
{move || items.get().iter().enumerate().map(|(i, item)| view! {
|
||||
<li key={i.to_string()}>
|
||||
<strong>{ item.name.clone() }</strong> - { item.description.clone() }
|
||||
<ul>
|
||||
|
|
Loading…
Reference in New Issue