From 8c03fa35a13096b2026e8016f1ad9b0da70ee23f Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Mon, 9 Dec 2024 14:58:05 +0300 Subject: [PATCH] fix: fix App component signal handling and on_submit prop - Replaced incorrect path statement in `add_item` with proper use of `set_items.update` for signal mutation. - Fixed dynamic dispatch for `on_submit` by boxing the `add_item` closure. - Simplified `items_signal` usage by removing unnecessary `.clone()`. - Improved code consistency and alignment with the latest Leptos updates. --- src/app.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app.rs b/src/app.rs index 8edd2f8..4bcffff 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,15 +1,16 @@ use leptos::*; use crate::components::{item_form::ItemForm, items_list::ItemsList}; use crate::models::item::Item; +use uuid::Uuid; #[component] pub fn App() -> impl IntoView { let (items_signal, set_items) = create_signal(Vec::::new()); let add_item = move |name: String, description: String, tags: Vec<(String, String)>| { - set_items;(|mut items: Vec| { + set_items.update(|items| { items.push(Item { - id: uuid::Uuid::new_v4().to_string(), + id: Uuid::new_v4().to_string(), name, description, tags, @@ -19,9 +20,9 @@ pub fn App() -> impl IntoView { view! {
-

CompareWare

+

{ "CompareWare" }

- +
} -} \ No newline at end of file +}