it almost lives?
This commit is contained in:
1 parent
d637ef187c
commit
5f0dd3af3e
43 files changed
+506
-244
No files matched your search
@@ -26,7 +26,7 @@ Unlike other routers in the Rust ecosystem, our router is built declaratively. T
|
||||
```rust, no_run
|
||||
rsx!{
|
||||
// All of our routes will be rendered inside this Router component
|
||||
Router {
|
||||
Router::<Route> {
|
||||
// if the current location is "/home", render the Home component
|
||||
Route { to: "/home", Home {} }
|
||||
// if the current location is "/blog", render the Blog component
|
||||
@@ -43,7 +43,7 @@ We can fix this one of two ways:
|
||||
|
||||
```rust, no_run
|
||||
rsx!{
|
||||
Router {
|
||||
Router::<Route> {
|
||||
Route { to: "/home", Home {} }
|
||||
Route { to: "/blog", Blog {} }
|
||||
// if the current location doesn't match any of the above routes, render the NotFound component
|
||||
@@ -56,7 +56,7 @@ rsx!{
|
||||
|
||||
```rust, no_run
|
||||
rsx!{
|
||||
Router {
|
||||
Router::<Route> {
|
||||
Route { to: "/home", Home {} }
|
||||
Route { to: "/blog", Blog {} }
|
||||
// if the current location doesn't match any of the above routes, redirect to "/home"
|
||||
|
||||
@@ -28,7 +28,7 @@ Ao contrário de outros roteadores no ecossistema Rust, nosso roteador é constr
|
||||
|
||||
```rust, no_run
|
||||
rsx!{
|
||||
Router {
|
||||
Router::<Route> {
|
||||
Route { to: "/home", Home {} }
|
||||
Route { to: "/blog", Blog {} }
|
||||
}
|
||||
@@ -43,7 +43,7 @@ Podemos corrigir isso de duas maneiras:
|
||||
|
||||
```rust, no_run
|
||||
rsx!{
|
||||
Router {
|
||||
Router::<Route> {
|
||||
Route { to: "/home", Home {} }
|
||||
Route { to: "/blog", Blog {} }
|
||||
Route { to: "", NotFound {} }
|
||||
@@ -55,7 +55,7 @@ rsx!{
|
||||
|
||||
```rust, no_run
|
||||
rsx!{
|
||||
Router {
|
||||
Router::<Route> {
|
||||
Route { to: "/home", Home {} }
|
||||
Route { to: "/blog", Blog {} }
|
||||
Redirect { from: "", to: "/home" }
|
||||
|
||||
@@ -72,7 +72,7 @@ Apps with routers are _really_ simple now. It's easy to compose the "Router", a
|
||||
```rust, no_run
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
Router {
|
||||
Router::<Route> {
|
||||
onchange: move |_| log::info!("Route changed!"),
|
||||
ul {
|
||||
Link { to: "/", li { "Go home!" } }
|
||||
|
||||
@@ -17,7 +17,7 @@ enum Route {
|
||||
#[inline_props]
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: app
|
||||
|
||||
@@ -35,7 +35,7 @@ enum Route {
|
||||
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ fn NavBar(cx: Scope) -> Element {
|
||||
li { Link { to: Route::BlogList {}, "Blog" } }
|
||||
}
|
||||
}
|
||||
Outlet {}
|
||||
Outlet::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ fn Home(cx: Scope) -> Element {
|
||||
fn Blog(cx: Scope) -> Element {
|
||||
render! {
|
||||
h1 { "Blog" }
|
||||
Outlet {}
|
||||
Outlet::<Route> {}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: blog
|
||||
|
||||
@@ -20,7 +20,7 @@ fn main() {}
|
||||
fn GoToDioxus(cx: Scope) -> Element {
|
||||
render! {
|
||||
Link {
|
||||
to: NavigationTarget::External("https://dioxuslabs.com".into()),
|
||||
to: "https://dioxuslabs.com",
|
||||
"ExternalTarget target"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ enum Route {
|
||||
#[inline_props]
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: app
|
||||
|
||||
@@ -39,7 +39,7 @@ enum Route {
|
||||
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ fn NavBar(cx: Scope) -> Element {
|
||||
li { Link { to: Route::BlogList {}, "Blog" } }
|
||||
}
|
||||
}
|
||||
Outlet {}
|
||||
Outlet::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ fn Home(cx: Scope) -> Element {
|
||||
fn Blog(cx: Scope) -> Element {
|
||||
render! {
|
||||
h1 { "Blog" }
|
||||
Outlet {}
|
||||
Outlet::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ enum Route {
|
||||
#[inline_props]
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {
|
||||
Router::<Route> {
|
||||
config: || RouterConfig::default().history(WebHistory::default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ fn NavBar(cx: Scope) -> Element {
|
||||
}
|
||||
}
|
||||
}
|
||||
Outlet {}
|
||||
Outlet::<Route> {}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: nav
|
||||
@@ -41,7 +41,7 @@ fn NavBar(cx: Scope) -> Element {
|
||||
#[inline_props]
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: app
|
||||
|
||||
@@ -14,7 +14,7 @@ enum Route {
|
||||
#[inline_props]
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ fn NavBar(cx: Scope) -> Element {
|
||||
}
|
||||
}
|
||||
// The Outlet component will render child routes (In this case just the Home component) inside the Outlet component
|
||||
Outlet {}
|
||||
Outlet::<Route> {}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: nav
|
||||
@@ -35,7 +35,7 @@ fn NavBar(cx: Scope) -> Element {
|
||||
#[inline_props]
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: app
|
||||
|
||||
@@ -16,7 +16,7 @@ fn Wrapper(cx: Scope) -> Element {
|
||||
render! {
|
||||
header { "header" }
|
||||
// The index route will be rendered here
|
||||
Outlet { }
|
||||
Outlet::<Route> { }
|
||||
footer { "footer" }
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ fn Index(cx: Scope) -> Element {
|
||||
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ enum Route {
|
||||
#[inline_props]
|
||||
fn App(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {
|
||||
Router::<Route> {
|
||||
config: || RouterConfig::default().history(WebHistory::default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ fn Index(cx: Scope) -> Element {
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
render! {
|
||||
Router {
|
||||
Router::<Route> {
|
||||
config: || RouterConfig::default().on_update(|state|{
|
||||
(state.current() == Route::Index {}).then_some(
|
||||
NavigationTarget::Internal(Route::Home {})
|
||||
|
||||
Reference in new issue
Block a user