Struct leptos_router::RouteProps
source · pub struct RouteProps<E, F, P>{
pub path: P,
pub view: F,
pub ssr: SsrMode,
pub methods: &'static [Method],
pub data: Option<Loader>,
pub trailing_slash: Option<TrailingSlash>,
pub children: Option<Children>,
}
Expand description
Props for the Route
component.
Describes a portion of the nested layout of the app, specifying the route it should match, the element it should display, and data that should be loaded alongside the route.
§Required Props
- path: [
P
]- The path fragment that this route should match. This can be static (
users
), include a parameter (:id
) or an optional parameter (:id?
), or match a wildcard (user/*any
).
- The path fragment that this route should match. This can be static (
- view: [
F
]- The view that should be shown when this route is matched. This can be any function
that returns a type that implements
IntoView
(like|| view! { <p>"Show this"</p> })
or|| view! { <MyComponent/>
} or even, for a component with no props,MyComponent
).
- The view that should be shown when this route is matched. This can be any function
that returns a type that implements
§Optional Props
- ssr:
SsrMode
- The mode that this route prefers during server-side rendering. Defaults to out-of-order streaming.
- methods: [
&'static [Method]
]- The HTTP methods that this route can handle (defaults to only
GET
).
- The HTTP methods that this route can handle (defaults to only
- data:
impl Into<Loader>
- A data-loading function that will be called when the route is matched. Its results can be
accessed with
use_route_data
.
- A data-loading function that will be called when the route is matched. Its results can be
accessed with
- trailing_slash:
TrailingSlash
- How this route should handle trailing slashes in its path.
Overrides any setting applied to
crate::components::Router
. Serves as a default for any inner Routes.
- How this route should handle trailing slashes in its path.
Overrides any setting applied to
- children:
Children
children
may be empty or include nested routes.
Fields§
§path: P
The path fragment that this route should match. This can be static (users
),
include a parameter (:id
) or an optional parameter (:id?
), or match a
wildcard (user/*any
).
view: F
The view that should be shown when this route is matched. This can be any function
that returns a type that implements IntoView
(like || view! { <p>"Show this"</p> })
or || view! { <MyComponent/>
} or even, for a component with no props, MyComponent
).
ssr: SsrMode
The mode that this route prefers during server-side rendering. Defaults to out-of-order streaming.
methods: &'static [Method]
The HTTP methods that this route can handle (defaults to only GET
).
data: Option<Loader>
A data-loading function that will be called when the route is matched. Its results can be
accessed with use_route_data
.
trailing_slash: Option<TrailingSlash>
How this route should handle trailing slashes in its path.
Overrides any setting applied to crate::components::Router
.
Serves as a default for any inner Routes.
children: Option<Children>
children
may be empty or include nested routes.
Implementations§
source§impl<E, F, P> RouteProps<E, F, P>
impl<E, F, P> RouteProps<E, F, P>
sourcepub fn builder() -> RoutePropsBuilder<E, F, P, ((), (), (), (), (), (), ())>
pub fn builder() -> RoutePropsBuilder<E, F, P, ((), (), (), (), (), (), ())>
Create a builder for building RouteProps
.
On the builder, call .path(...)
, .view(...)
, .ssr(...)
(optional), .methods(...)
(optional), .data(...)
(optional), .trailing_slash(...)
(optional), .children(...)
(optional) to set the values of the fields.
Finally, call .build()
to create the instance of RouteProps
.
Trait Implementations§
Auto Trait Implementations§
impl<E, F, P> Freeze for RouteProps<E, F, P>
impl<E, F, P> !RefUnwindSafe for RouteProps<E, F, P>
impl<E, F, P> !Send for RouteProps<E, F, P>
impl<E, F, P> !Sync for RouteProps<E, F, P>
impl<E, F, P> Unpin for RouteProps<E, F, P>
impl<E, F, P> !UnwindSafe for RouteProps<E, F, P>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more