Merge pull request #107 from autarch/autarch/half-assed-router

A partial implementation of the router and associated bits
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2022-01-18 00:01:34 -05:00
commit 8d3ac3ff14
8 files changed
+204 -60

No files matched your search

+9 -3
View File
@@ -2,6 +2,7 @@
use dioxus::prelude::*;
use dioxus::router::{Link, Route, Router};
use serde::Deserialize;
fn main() {
dioxus::desktop::launch(app);
@@ -30,7 +31,7 @@ fn app(cx: Scope) -> Element {
}
fn BlogPost(cx: Scope) -> Element {
let post = dioxus::router::use_route(&cx).last_segment()?;
let post = dioxus::router::use_route(&cx).last_segment();
cx.render(rsx! {
div {
@@ -40,9 +41,14 @@ fn BlogPost(cx: Scope) -> Element {
})
}
#[derive(Deserialize)]
struct Query {
bold: bool,
}
fn User(cx: Scope) -> Element {
let post = dioxus::router::use_route(&cx).last_segment()?;
let bold = dioxus::router::use_route(&cx).param::<bool>("bold");
let post = dioxus::router::use_route(&cx).last_segment();
let query = dioxus::router::use_route(&cx).query::<Query>();
cx.render(rsx! {
div {