-
I made a minimal example of code that "should" be working from my understanding, but isn't. use dioxus::prelude::*;
fn main() {
#[cfg(feature = "ssr")] {
use dioxus_fullstack::prelude::*;
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
let app = axum::routing::Router::new()
.serve_dioxus_application(
"",
ServeConfigBuilder::new(App, ())
);
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3000));
println!("Listening on: {addr}");
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
})
}
}
#[component]
pub fn App(cx: Scope) -> Element {
let count = use_state(cx, || vec![0, 1, 2, 3, 4]);
render! {
button {
onclick: move |_| {
count.make_mut().remove(0);
},
"ok {count[0]}"
}
}
} When I launch this code, everything compiles but when I click on the button, it stays at "ok 0". Why ?Command used: $ dx build --features web --release $ cargo run --features ssr --release |
Beta Was this translation helpful? Give feedback.
Answered by
tkr-sh
Jan 14, 2024
Replies: 1 comment
-
This doesn't work because the client has nothing to execute. Thanks to @marc2332 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tkr-sh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work because the client has nothing to execute.
The
main.rs
file is executed both on client-side and server-side.But in this case, the client has nothing to execute, therefore nothing occurs.
Thanks to @marc2332