Skip to content

Commit

Permalink
Fix the current route in ssr fullstack rendering (#3153)
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff authored Nov 1, 2024
1 parent caa9759 commit 412f0b5
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 2 deletions.
188 changes: 186 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/fullstack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ dioxus-cli-config = { workspace = true, optional = true }

dioxus-devtools = { workspace = true, optional = true }
aws-lc-rs = { version = "1.8.1", optional = true }
dioxus-history.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio = { workspace = true, features = ["rt", "sync"], optional = true }
Expand Down
4 changes: 4 additions & 0 deletions packages/fullstack/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use dioxus_lib::document::Document;
use dioxus_ssr::Renderer;
use futures_channel::mpsc::Sender;
use futures_util::{Stream, StreamExt};
use std::rc::Rc;
use std::sync::Arc;
use std::sync::RwLock;
use std::{collections::HashMap, future::Future};
Expand Down Expand Up @@ -168,6 +169,9 @@ impl SsrRendererPool {
let mut virtual_dom = virtual_dom_factory();
let document = std::rc::Rc::new(crate::document::server::ServerDocument::default());
virtual_dom.provide_root_context(document.clone());
virtual_dom.provide_root_context(Rc::new(
dioxus_history::MemoryHistory::with_initial_path(&route),
) as Rc<dyn dioxus_history::History>);
virtual_dom.provide_root_context(document.clone() as std::rc::Rc<dyn Document>);

// poll the future, which may call server_context()
Expand Down

0 comments on commit 412f0b5

Please sign in to comment.