create cfg factory

This commit is contained in:
Evan Almloff committed 2023-06-01 13:13:50 -05:00
1 parent 037a248ad9
commit 67992f7da9
6 files changed
+90 -72

No files matched your search

+5 -8
View File
@@ -2,14 +2,13 @@
use dioxus::prelude::*;
use dioxus_router::prelude::*;
use serde::{Deserialize, Serialize};
fn prepare(path: impl Into<String>) -> VirtualDom {
let mut vdom = VirtualDom::new_with_props(App, AppProps { path: path.into() });
let _ = vdom.rebuild();
return vdom;
#[derive(Routable, Clone, Serialize, Deserialize)]
#[derive(Routable, Clone)]
#[rustfmt::skip]
enum Route {
#[route("/")]
@@ -36,15 +35,13 @@ fn prepare(path: impl Into<String>) -> VirtualDom {
}
fn App(cx: Scope<AppProps>) -> Element {
let cfg = RouterConfiguration {
history: Box::new(MemoryHistory::with_initial_path(cx.props.path.clone()).unwrap()),
..Default::default()
};
render! {
h1 { "App" }
Router {
config: cfg
config: {
let path = cx.props.path.clone();
move || RouterConfiguration::default().history(MemoryHistory::with_initial_path(path).unwrap())
}
}
}
}