2022-07-07 08:50:36 +00:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
fn main() {
|
2022-07-09 19:15:20 +00:00
|
|
|
dioxus_desktop::launch(App);
|
2022-07-07 08:50:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ANCHOR: App
|
|
|
|
fn App(cx: Scope) -> Element {
|
|
|
|
cx.render(rsx! {
|
|
|
|
Likes {
|
|
|
|
score: 42,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// ANCHOR_END: App
|
|
|
|
|
|
|
|
// ANCHOR: Likes
|
|
|
|
// Remember: Owned props must implement `PartialEq`!
|
|
|
|
#[derive(PartialEq, Props)]
|
|
|
|
struct LikesProps {
|
|
|
|
score: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn Likes(cx: Scope<LikesProps>) -> Element {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
"This post has ",
|
|
|
|
b { "{cx.props.score}" },
|
|
|
|
" likes"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// ANCHOR_END: Likes
|