Fix hydration of link element (#4561)
* Fix hydration of link element * revert some logging changes * clean up fullstack history provider * fix router tests * fix document context type
This commit is contained in:
1 parent
6cd4453662
commit
021565c171
12 files changed
+141
-109
No files matched your search
@@ -9,7 +9,7 @@ use dioxus_core::{
|
||||
has_context, provide_error_boundary, DynamicNode, ErrorContext, ScopeId, SuspenseContext,
|
||||
VNode, VirtualDom,
|
||||
};
|
||||
use dioxus_fullstack_hooks::history::FullstackHistory;
|
||||
use dioxus_fullstack_hooks::history::provide_fullstack_history_context;
|
||||
use dioxus_fullstack_hooks::{StreamingContext, StreamingStatus};
|
||||
use dioxus_fullstack_protocol::{HydrationContext, SerializedHydrationData};
|
||||
use dioxus_isrg::{CachedRender, IncrementalRendererError, RenderFreshness};
|
||||
@@ -192,24 +192,22 @@ impl SsrRendererPool {
|
||||
virtual_dom.provide_root_context(document.clone());
|
||||
// If there is a base path, trim the base path from the route and add the base path formatting to the
|
||||
// history provider
|
||||
let history;
|
||||
if let Some(base_path) = base_path() {
|
||||
let history = if let Some(base_path) = base_path() {
|
||||
let base_path = base_path.trim_matches('/');
|
||||
let base_path = format!("/{base_path}");
|
||||
let route = route.strip_prefix(&base_path).unwrap_or(&route);
|
||||
history =
|
||||
dioxus_history::MemoryHistory::with_initial_path(route).with_prefix(base_path);
|
||||
dioxus_history::MemoryHistory::with_initial_path(route).with_prefix(base_path)
|
||||
} else {
|
||||
history = dioxus_history::MemoryHistory::with_initial_path(&route);
|
||||
}
|
||||
// Wrap the memory history in a fullstack history provider to provide the initial route for hydration
|
||||
let history = FullstackHistory::new_server(history);
|
||||
dioxus_history::MemoryHistory::with_initial_path(&route)
|
||||
};
|
||||
|
||||
let streaming_context = in_root_scope(&virtual_dom, StreamingContext::new);
|
||||
virtual_dom.provide_root_context(Rc::new(history) as Rc<dyn dioxus_history::History>);
|
||||
virtual_dom.provide_root_context(document.clone() as Rc<dyn dioxus_document::Document>);
|
||||
virtual_dom.provide_root_context(streaming_context);
|
||||
|
||||
// Wrap the memory history in a fullstack history provider to provide the initial route for hydration
|
||||
in_root_scope(&virtual_dom, || provide_fullstack_history_context(history));
|
||||
|
||||
// rebuild the virtual dom
|
||||
virtual_dom.rebuild_in_place();
|
||||
|
||||
|
||||
Reference in new issue
Block a user