fix the incremental feature on the router
This commit is contained in:
1 parent
fb01a276b0
commit
2034591ab3
3 files changed
+16
-9
No files matched your search
@@ -32,7 +32,7 @@ dioxus-cli-config = { workspace = true }
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
ssr = ["dioxus-ssr", "tokio"]
|
ssr = ["dioxus-ssr/incremental", "tokio", "dioxus-fullstack?/ssr"]
|
||||||
liveview = ["dioxus-liveview", "tokio", "dep:serde", "serde_json"]
|
liveview = ["dioxus-liveview", "tokio", "dep:serde", "serde_json"]
|
||||||
wasm_test = []
|
wasm_test = []
|
||||||
serde = ["dep:serde", "gloo-utils?/serde"]
|
serde = ["dep:serde", "gloo-utils?/serde"]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use core::pin::Pin;
|
|||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus_lib::prelude::*;
|
||||||
use dioxus_ssr::incremental::{
|
use dioxus_ssr::incremental::{
|
||||||
IncrementalRenderer, IncrementalRendererError, RenderFreshness, WrapBody,
|
IncrementalRenderer, IncrementalRendererError, RenderFreshness, WrapBody,
|
||||||
};
|
};
|
||||||
@@ -50,7 +50,7 @@ where
|
|||||||
&mut tokio::io::sink(),
|
&mut tokio::io::sink(),
|
||||||
|vdom| {
|
|vdom| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let _ = vdom.rebuild();
|
vdom.rebuild_in_place();
|
||||||
vdom.wait_for_suspense().await;
|
vdom.wait_for_suspense().await;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -87,13 +87,21 @@ where
|
|||||||
<Rt as FromStr>::Err: std::fmt::Display,
|
<Rt as FromStr>::Err: std::fmt::Display,
|
||||||
W: tokio::io::AsyncWrite + Unpin + Send,
|
W: tokio::io::AsyncWrite + Unpin + Send,
|
||||||
{
|
{
|
||||||
#[component]
|
#[derive(Clone)]
|
||||||
fn RenderPath<R>(path: R) -> Element
|
struct RootProps<Rt>(Rt);
|
||||||
|
|
||||||
|
impl<Rt> PartialEq for RootProps<Rt> {
|
||||||
|
fn eq(&self, _: &Self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn RenderPath<R>(props: RootProps<R>) -> Element
|
||||||
where
|
where
|
||||||
R: Routable,
|
R: Routable,
|
||||||
<R as FromStr>::Err: std::fmt::Display,
|
<R as FromStr>::Err: std::fmt::Display,
|
||||||
{
|
{
|
||||||
let path = path.clone();
|
let path = props.0;
|
||||||
rsx! {
|
rsx! {
|
||||||
Router::<R> {
|
Router::<R> {
|
||||||
config: || RouterConfig::default().history(MemoryHistory::with_initial_path(path))
|
config: || RouterConfig::default().history(MemoryHistory::with_initial_path(path))
|
||||||
@@ -104,8 +112,7 @@ where
|
|||||||
renderer
|
renderer
|
||||||
.render(
|
.render(
|
||||||
route.to_string(),
|
route.to_string(),
|
||||||
RenderPath,
|
|| VirtualDom::new_with_props(RenderPath, RootProps(route)),
|
||||||
RenderPathProps { path: route },
|
|
||||||
writer,
|
writer,
|
||||||
modify_vdom,
|
modify_vdom,
|
||||||
wrapper,
|
wrapper,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ macro_rules! default_history {
|
|||||||
return Box::new(AnyHistoryProviderImplWrapper::new(WebHistory::<R>::default()));
|
return Box::new(AnyHistoryProviderImplWrapper::new(WebHistory::<R>::default()));
|
||||||
// If we are using dioxus fullstack and the ssr feature is enabled, use the memory history with the initial path set to the current path in fullstack
|
// If we are using dioxus fullstack and the ssr feature is enabled, use the memory history with the initial path set to the current path in fullstack
|
||||||
#[cfg(all(feature = "fullstack", feature = "ssr"))]
|
#[cfg(all(feature = "fullstack", feature = "ssr"))]
|
||||||
return dioxus_router::prelude::MemoryHistory::with_initial_path(
|
return MemoryHistory::with_initial_path(
|
||||||
dioxus_fullstack::prelude::server_context()
|
dioxus_fullstack::prelude::server_context()
|
||||||
.request_parts()
|
.request_parts()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|||||||
Reference in new issue
Block a user