Skip to content

Commit

Permalink
ex: counter_url_query; to stable (#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
solweo authored Apr 5, 2024
1 parent 03ac690 commit a82af61
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/counter_url_query/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ codegen-units = 1
lto = true

[dependencies]
leptos = { path = "../../leptos", features = ["csr", "nightly"] }
leptos = { path = "../../leptos", features = ["csr"] }
leptos_router = { path = "../../router", features = ["csr"] }
console_log = "1"
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/counter_url_query/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2024-03-31"
channel = "stable"
14 changes: 7 additions & 7 deletions examples/counter_url_query/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ use leptos_router::*;
#[component]
pub fn SimpleQueryCounter() -> impl IntoView {
let (count, set_count) = create_query_signal::<i32>("count");
let clear = move |_| set_count(None);
let decrement = move |_| set_count(Some(count().unwrap_or(0) - 1));
let increment = move |_| set_count(Some(count().unwrap_or(0) + 1));
let clear = move |_| set_count.set(None);
let decrement = move |_| set_count.set(Some(count.get().unwrap_or(0) - 1));
let increment = move |_| set_count.set(Some(count.get().unwrap_or(0) + 1));

let (msg, set_msg) = create_query_signal::<String>("message");
let update_msg = move |ev| {
let new_msg = event_target_value(&ev);
if new_msg.is_empty() {
set_msg(None);
set_msg.set(None);
} else {
set_msg(Some(new_msg));
set_msg.set(Some(new_msg));
}
};

view! {
<div>
<button on:click=clear>"Clear"</button>
<button on:click=decrement>"-1"</button>
<span>"Value: " {move || count().unwrap_or(0)} "!"</span>
<span>"Value: " {move || count.get().unwrap_or(0)} "!"</span>
<button on:click=increment>"+1"</button>

<br />

<input
prop:value=move || msg().unwrap_or_default()
prop:value=move || msg.get().unwrap_or_default()
on:input=update_msg
/>
</div>
Expand Down

0 comments on commit a82af61

Please sign in to comment.