mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-24 19:43:10 +00:00
31 lines
550 B
Rust
31 lines
550 B
Rust
|
#![allow(non_snake_case)]
|
||
|
|
||
|
use dioxus::prelude::*;
|
||
|
use dioxus_signals::*;
|
||
|
|
||
|
fn main() {
|
||
|
dioxus_desktop::launch(app);
|
||
|
}
|
||
|
|
||
|
fn app(cx: Scope) -> Element {
|
||
|
let signal = use_signal(cx, || 0);
|
||
|
let doubled = use_selector(cx, move || signal * 2);
|
||
|
|
||
|
render! {
|
||
|
button {
|
||
|
onclick: move |_| *signal.write() += 1,
|
||
|
"Increase"
|
||
|
}
|
||
|
Child {
|
||
|
signal: doubled
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[inline_props]
|
||
|
fn Child(cx: Scope, signal: ReadOnlySignal<usize>) -> Element {
|
||
|
render! {
|
||
|
"{signal}"
|
||
|
}
|
||
|
}
|