fix routers without an index route (#2477)
This commit is contained in:
1 parent
5e57779435
commit
b6cdcb4e7f
3 files changed
+49
-6
No files matched your search
@@ -1,2 +1,3 @@
|
||||
mod link;
|
||||
mod outlet;
|
||||
mod without_index;
|
||||
@@ -0,0 +1,41 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
// Tests for regressions of <https://github.com/DioxusLabs/dioxus/issues/2468>
|
||||
#[test]
|
||||
fn router_without_index_route_parses() {
|
||||
let mut vdom = VirtualDom::new_with_props(
|
||||
App,
|
||||
AppProps {
|
||||
path: Route::Test {},
|
||||
},
|
||||
);
|
||||
vdom.rebuild_in_place();
|
||||
let as_string = dioxus_ssr::render(&vdom);
|
||||
assert_eq!(as_string, "<div>router with no index route renders</div>")
|
||||
}
|
||||
|
||||
#[derive(Routable, Clone, Copy, PartialEq, Debug)]
|
||||
enum Route {
|
||||
#[route("/test")]
|
||||
Test {},
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn Test() -> Element {
|
||||
rsx! {
|
||||
div {
|
||||
"router with no index route renders"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn App(path: Route) -> Element {
|
||||
rsx! {
|
||||
Router::<Route> {
|
||||
config: {
|
||||
move || RouterConfig::default().history(MemoryHistory::with_initial_path(path))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user