From c26a96d8a671497ffb1613fb6b10d52dea8edc4e Mon Sep 17 00:00:00 2001 From: Marc-Stefan Cassola Date: Tue, 16 Jul 2024 19:57:30 +0100 Subject: [PATCH] =?UTF-8?q?use=5Fstorage=20now=20always=20writes=20the=20d?= =?UTF-8?q?efault=20value=20to=20storage=20if=20the=20key=20doesn=E2=80=99?= =?UTF-8?q?t=20exist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/storage/use_storage.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/storage/use_storage.rs b/src/storage/use_storage.rs index e98591e..1c31fea 100644 --- a/src/storage/use_storage.rs +++ b/src/storage/use_storage.rs @@ -272,13 +272,6 @@ where } }; - // Fetch initial value - if delay_during_hydration && leptos::leptos_dom::HydrationCtx::is_hydrating() { - request_animation_frame(fetch_from_storage.clone()); - } else { - fetch_from_storage(); - } - // Fires when storage needs to be fetched let notify = create_trigger(); @@ -329,6 +322,13 @@ where ); } + // Fetch initial value + if delay_during_hydration && leptos::leptos_dom::HydrationCtx::is_hydrating() { + request_animation_frame(fetch_from_storage.clone()); + } else { + fetch_from_storage(); + } + if listen_to_storage_changes { let check_key = key.as_ref().to_owned(); // Listen to global storage events