2021-07-30 21:04:04 +00:00
|
|
|
//! Basic example that renders a simple VNode to the browser.
|
|
|
|
|
2021-08-24 19:12:20 +00:00
|
|
|
// all these imports are done automatically with the `dioxus` crate and `prelude`
|
|
|
|
// need to do them manually for this example
|
2021-07-30 21:04:04 +00:00
|
|
|
use dioxus::events::on::MouseEvent;
|
|
|
|
use dioxus_core as dioxus;
|
|
|
|
use dioxus_core::prelude::*;
|
|
|
|
use dioxus_hooks::*;
|
|
|
|
use dioxus_html as dioxus_elements;
|
|
|
|
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
use dioxus_web::*;
|
2021-08-24 19:12:20 +00:00
|
|
|
use std::future::Future;
|
|
|
|
use std::{pin::Pin, time::Duration};
|
2021-07-30 21:04:04 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Setup logging
|
|
|
|
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
|
|
|
console_error_panic_hook::set_once();
|
|
|
|
|
|
|
|
// Run the app
|
2021-08-24 19:12:20 +00:00
|
|
|
dioxus_web::launch(APP, |c| c)
|
2021-07-30 21:04:04 +00:00
|
|
|
}
|
|
|
|
|
2021-09-22 06:44:01 +00:00
|
|
|
static APP: FC<()> = |cx, props| {
|
2021-08-24 16:43:46 +00:00
|
|
|
let mut count = use_state(cx, || 3);
|
2021-07-30 21:04:04 +00:00
|
|
|
|
|
|
|
cx.render(rsx! {
|
2021-09-22 06:44:01 +00:00
|
|
|
button {
|
|
|
|
// onclick: move |_| count += 1,
|
|
|
|
onmouseover: move |_| count += 5,
|
|
|
|
onmouseout: move |_| count -= 5,
|
|
|
|
"Click to add."
|
|
|
|
"Current count: {count}"
|
2021-07-30 21:04:04 +00:00
|
|
|
}
|
2021-09-22 06:44:01 +00:00
|
|
|
// div {
|
|
|
|
// button {
|
|
|
|
// onclick: move |_| count += 1,
|
|
|
|
// "Click to add."
|
|
|
|
// "Current count: {count}"
|
|
|
|
// }
|
|
|
|
// ul {
|
|
|
|
// {(0..*count).map(|f| rsx!{
|
|
|
|
// li { "a - {f}" }
|
|
|
|
// li { "b - {f}" }
|
|
|
|
// li { "c - {f}" }
|
|
|
|
// })}
|
|
|
|
// }
|
|
|
|
// Child {}
|
|
|
|
// }
|
2021-07-30 21:04:04 +00:00
|
|
|
})
|
|
|
|
};
|
2021-08-24 19:12:20 +00:00
|
|
|
|
2021-09-22 06:44:01 +00:00
|
|
|
// static Child: FC<()> = |cx, props| {
|
|
|
|
// cx.render(rsx! {
|
|
|
|
// div {
|
|
|
|
// div {
|
|
|
|
// div {
|
|
|
|
// "hello child"
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// };
|