fix more examples

This commit is contained in:
Evan Almloff committed 2024-01-16 12:28:21 -06:00
1 parent db35a9b48c
commit 407a82588a
59 files changed
+166 -195

No files matched your search

+2 -6
View File
@@ -60,11 +60,7 @@ fn app(cx: Scope<AppProps>) -> Element {
rsx! {
h1 { "hello axum! {count}" }
button {
class: "increment-button",
onclick: move |_| count += 1,
"Increment"
}
button { class: "increment-button", onclick: move |_| count += 1, "Increment" }
button {
class: "server-button",
onclick: move |_| {
@@ -80,7 +76,7 @@ fn app(cx: Scope<AppProps>) -> Element {
"Run a server function!"
}
"Server said: {text}"
})
}
}
#[server(PostServerData)]
+1 -1
View File
@@ -20,7 +20,7 @@ fn app() -> Element {
}
input { value: "hello input" }
div { class: "style-div", color: "red", "colored text" }
})
}
}
#[tokio::main]
+1 -3
View File
@@ -7,7 +7,5 @@ license = "MIT OR Apache-2.0"
publish = false
[dependencies]
dioxus = { path = "../../packages/dioxus" }
dioxus-web = { path = "../../packages/web" }
dioxus-html = { path = "../../packages/html" }
dioxus = { path = "../../packages/dioxus", features = ["web"]}
serde_json = "1.0.96"
+4 -7
View File
@@ -6,8 +6,6 @@ fn app() -> Element {
let mut num = use_signal(|| 0);
let eval_result = use_signal(String::new);
let eval_provider = dioxus_html::prelude::use_eval(cx);
rsx! {
div {
"hello axum! {num}"
@@ -25,27 +23,26 @@ fn app() -> Element {
button {
class: "eval-button",
onclick: move |_| {
let eval = eval_provider(
let eval = eval(
r#"
window.document.title = 'Hello from Dioxus Eval!';
dioxus.send("returned eval value");
"#,
)
.unwrap();
let setter = eval_result.setter();
async move {
let result = eval.recv().await;
if let Ok(serde_json::Value::String(string)) = result {
setter(string);
eval_result.set(string);
}
}
},
"Eval"
}
div { class: "eval-result", "{eval_result}" }
})
}
}
fn main() {
dioxus_web::launch(app);
launch_web(app);
}