diff --git a/example/start-csr/Cargo.toml b/example/start-csr/Cargo.toml index b90ed7b..11e5958 100644 --- a/example/start-csr/Cargo.toml +++ b/example/start-csr/Cargo.toml @@ -18,6 +18,7 @@ leptos_query_devtools = { path = "../../devtools", features = ["csr", "force"]} gloo-timers = "0.3.0" serde = { version = "1.0" } reqwest = { version = "0.11.24", features = ["json"] } +leptos-use = "0.10.3" # utils # strum = { version = "0.25", features = ["derive", "strum_macros"] } diff --git a/example/start-csr/src/layout.rs b/example/start-csr/src/layout.rs index f5ce45f..58a06a4 100644 --- a/example/start-csr/src/layout.rs +++ b/example/start-csr/src/layout.rs @@ -1,7 +1,11 @@ +use std::str::FromStr; + use leptos::*; use leptos_meta::Html; use leptos_query::query_persister::{IndexedDbPersister, LocalStoragePersister}; use leptos_query::use_query_client; +use leptos_use::storage::use_local_storage; +use leptos_use::utils::FromToStringCodec; use crate::components::switch::Switch; @@ -54,7 +58,10 @@ fn ThemeToggle() -> impl IntoView { #[component] fn SelectPersister() -> impl IntoView { - let persister = create_rw_signal(Persister::None); + let (persister, set_persister, _) = + use_local_storage::(Persister::None); + + create_effect(move |_| set_persister(persister.get_untracked())); create_effect(move |_| { let client = use_query_client(); @@ -84,12 +91,12 @@ fn SelectPersister() -> impl IntoView {