fix: <For/> in todomvc example (#504)

This commit is contained in:
Greg Johnston 2023-02-11 16:30:09 -05:00 committed by GitHub
parent d1ae3b49cc
commit 1cba54d47e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,4 @@
use leptos::{ use leptos::{web_sys::HtmlInputElement, *};
web_sys::HtmlInputElement,
*,
};
use storage::TodoSerialized; use storage::TodoSerialized;
use uuid::Uuid; use uuid::Uuid;
@ -15,7 +12,8 @@ const STORAGE_KEY: &str = "todos-leptos";
// Basic operations to manipulate the todo list: nothing really interesting here // Basic operations to manipulate the todo list: nothing really interesting here
impl Todos { impl Todos {
pub fn new(cx: Scope) -> Self { pub fn new(cx: Scope) -> Self {
let starting_todos = if let Ok(Some(storage)) = window().local_storage() { let starting_todos = if let Ok(Some(storage)) = window().local_storage()
{
storage storage
.get_item(STORAGE_KEY) .get_item(STORAGE_KEY)
.ok() .ok()
@ -139,7 +137,8 @@ pub fn TodoMVC(cx: Scope) -> impl IntoView {
// Handle the three filter modes: All, Active, and Completed // Handle the three filter modes: All, Active, and Completed
let (mode, set_mode) = create_signal(cx, Mode::All); let (mode, set_mode) = create_signal(cx, Mode::All);
window_event_listener("hashchange", move |_| { window_event_listener("hashchange", move |_| {
let new_mode = location_hash().map(|hash| route(&hash)).unwrap_or_default(); let new_mode =
location_hash().map(|hash| route(&hash)).unwrap_or_default();
set_mode(new_mode); set_mode(new_mode);
}); });
@ -227,7 +226,7 @@ pub fn TodoMVC(cx: Scope) -> impl IntoView {
<For <For
each=filtered_todos each=filtered_todos
key=|todo| todo.id key=|todo| todo.id
view=move |todo: Todo| view! { cx, <Todo todo /> } view=move |cx, todo: Todo| view! { cx, <Todo todo /> }
/> />
</ul> </ul>
</section> </section>