use leptos::*; use leptos_use::docs::{demo_or_body, Note}; use leptos_use::storage::{use_local_storage, JsonCodec}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct BananaState { pub name: String, pub wearing: String, pub descending: String, pub count: u32, } impl Default for BananaState { fn default() -> Self { Self { name: "Bananas".to_string(), wearing: "pyjamas".to_string(), descending: "stairs".to_string(), count: 2, } } } #[component] fn Demo() -> impl IntoView { let (state, set_state, reset) = use_local_storage::("banana-state"); let (state2, _, _) = use_local_storage::("banana-state"); view! { ().unwrap() as u32) } type="number" min="0" step="1" max="1000" />

"Second " "use_storage" ":"

{move || format!("{:#?}", state2.get())}
"The values are persistent. When you reload the page or " "open a second window" ", the values will be the same." } } fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); mount_to(demo_or_body(), || { view! { } }) }