update doc examples

This commit is contained in:
Evan Almloff committed 2023-05-31 15:51:26 -05:00
1 parent 35befa1784
commit 09cabe4e8b
22 files changed
+474 -518

No files matched your search

+12 -12
View File
@@ -1,10 +1,10 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_router::prelude::*;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::str::FromStr;
fn prepare<R: Routable>() -> String
fn prepare<R: Routable + Serialize + DeserializeOwned>() -> String
where
<R as FromStr>::Err: std::fmt::Display,
{
@@ -28,7 +28,7 @@ where
}
}
fn App<R: Routable>(cx: Scope<AppProps<R>>) -> Element
fn App<R: Routable + Serialize + DeserializeOwned>(cx: Scope<AppProps<R>>) -> Element
where
<R as FromStr>::Err: std::fmt::Display,
{
@@ -46,7 +46,7 @@ where
#[test]
fn href_internal() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
@@ -84,7 +84,7 @@ fn href_internal() {
#[test]
fn href_external() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
@@ -122,7 +122,7 @@ fn href_external() {
#[test]
fn with_class() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
@@ -161,7 +161,7 @@ fn with_class() {
#[test]
fn with_active_class_active() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
@@ -194,7 +194,7 @@ fn with_active_class_active() {
#[test]
fn with_active_class_inactive() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
@@ -234,7 +234,7 @@ fn with_active_class_inactive() {
#[test]
fn with_id() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
@@ -273,7 +273,7 @@ fn with_id() {
#[test]
fn with_new_tab() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
@@ -312,7 +312,7 @@ fn with_new_tab() {
#[test]
fn with_new_tab_external() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
@@ -344,7 +344,7 @@ fn with_new_tab_external() {
#[test]
fn with_rel() {
#[derive(Routable, Clone)]
#[derive(Routable, Clone, Serialize, Deserialize)]
enum Route {
#[route("/")]
Root {},
+2 -1
View File
@@ -2,13 +2,14 @@
use dioxus::prelude::*;
use dioxus_router::{history::MemoryHistory, 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)]
#[derive(Routable, Clone, Serialize, Deserialize)]
#[rustfmt::skip]
enum Route {
#[route("/")]