make fullstack hello world compile
This commit is contained in:
1 parent
499e81fa82
commit
ae3e167cfe
19 files changed
+288
-155
No files matched your search
@@ -7,8 +7,7 @@ publish = false
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true }
|
||||
dioxus-fullstack = { workspace = true }
|
||||
dioxus = { workspace = true, features = ["fullstack"]}
|
||||
serde = "1.0.159"
|
||||
simple_logger = "4.2.0"
|
||||
tracing-wasm = "0.2.1"
|
||||
@@ -18,5 +17,5 @@ reqwest = "0.11.18"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
ssr = ["dioxus-fullstack/axum"]
|
||||
web = ["dioxus-fullstack/web"]
|
||||
ssr = ["dioxus/axum"]
|
||||
web = ["dioxus/web"]
|
||||
@@ -7,27 +7,17 @@
|
||||
|
||||
#![allow(non_snake_case, unused)]
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_fullstack::{
|
||||
launch::{self, LaunchBuilder},
|
||||
prelude::*,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Props, PartialEq, Debug, Default, Serialize, Deserialize, Clone)]
|
||||
struct AppProps {
|
||||
count: i32,
|
||||
}
|
||||
|
||||
fn app(cx: Scope<AppProps>) -> Element {
|
||||
let state =
|
||||
use_server_future((), |()| async move { get_server_data().await.unwrap() })?.value();
|
||||
fn app() -> Element {
|
||||
// let state = use_server_future(|| async move { get_server_data().await.unwrap() })?;
|
||||
// let state = state.value();
|
||||
|
||||
let mut count = use_signal(|| 0);
|
||||
let text = use_signal(|| "...".to_string());
|
||||
let eval = use_eval(cx);
|
||||
|
||||
rsx! {
|
||||
div { "Server state: {state}" }
|
||||
// div { "Server state: {state}" }
|
||||
h1 { "High-Five counter: {count}" }
|
||||
button { onclick: move |_| count += 1, "Up high!" }
|
||||
button { onclick: move |_| count -= 1, "Down low!" }
|
||||
@@ -50,9 +40,7 @@ fn app(cx: Scope<AppProps>) -> Element {
|
||||
|
||||
#[server]
|
||||
async fn post_server_data(data: String) -> Result<(), ServerFnError> {
|
||||
let axum::extract::Host(host): axum::extract::Host = extract().await?;
|
||||
println!("Server received: {}", data);
|
||||
println!("{:?}", host);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -68,5 +56,5 @@ fn main() {
|
||||
#[cfg(feature = "ssr")]
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
LaunchBuilder::new_with_props(app, AppProps { count: 0 }).launch()
|
||||
launch(app);
|
||||
}
|
||||
Reference in new issue
Block a user