updated examples with the new optional props
This commit is contained in:
1 parent
be55524e69
commit
a2825fb13c
3 files changed
+11
-13
No files matched your search
+11
-10
@@ -14,37 +14,38 @@ fn app(cx: Scope) -> Element {
|
|||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
Button {
|
Button {
|
||||||
a: "asd".to_string(),
|
a: "asd".to_string(),
|
||||||
c: Some("asd".to_string()),
|
c: "asd".to_string(),
|
||||||
d: "asd".to_string(),
|
d: Some("asd".to_string()),
|
||||||
e: "asd".to_string(),
|
e: "asd".to_string(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SthElse<T> = Option<T>;
|
||||||
|
|
||||||
#[derive(Props, PartialEq)]
|
#[derive(Props, PartialEq)]
|
||||||
struct ButtonProps {
|
struct ButtonProps {
|
||||||
a: String,
|
a: String,
|
||||||
|
|
||||||
#[props(default)]
|
#[props(default)]
|
||||||
b: Option<String>,
|
b: String,
|
||||||
|
|
||||||
#[props(default)]
|
|
||||||
c: Option<String>,
|
c: Option<String>,
|
||||||
|
|
||||||
#[props(default, strip_option)]
|
#[props(!optional)]
|
||||||
d: Option<String>,
|
d: Option<String>,
|
||||||
|
|
||||||
#[props(optional)]
|
#[props(optional)]
|
||||||
e: Option<String>,
|
e: SthElse<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Button(cx: Scope<ButtonProps>) -> Element {
|
fn Button(cx: Scope<ButtonProps>) -> Element {
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
button {
|
button {
|
||||||
"{cx.props.a}"
|
"{cx.props.a} | "
|
||||||
"{cx.props.b:?}"
|
"{cx.props.b:?} | "
|
||||||
"{cx.props.c:?}"
|
"{cx.props.c:?} | "
|
||||||
"{cx.props.d:?}"
|
"{cx.props.d:?} | "
|
||||||
"{cx.props.e:?}"
|
"{cx.props.e:?}"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ pub struct RedirectProps<'a> {
|
|||||||
/// // Relative path
|
/// // Relative path
|
||||||
/// Redirect { from: "", to: "../" }
|
/// Redirect { from: "", to: "../" }
|
||||||
/// ```
|
/// ```
|
||||||
#[props(optional)]
|
|
||||||
pub from: Option<&'a str>,
|
pub from: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ pub struct RouterProps<'a> {
|
|||||||
///
|
///
|
||||||
/// This will be used to trim any latent segments from the URL when your app is
|
/// This will be used to trim any latent segments from the URL when your app is
|
||||||
/// not deployed to the root of the domain.
|
/// not deployed to the root of the domain.
|
||||||
#[props(optional)]
|
|
||||||
pub base_url: Option<&'a str>,
|
pub base_url: Option<&'a str>,
|
||||||
|
|
||||||
/// Hook into the router when the route is changed.
|
/// Hook into the router when the route is changed.
|
||||||
@@ -33,7 +32,6 @@ pub struct RouterProps<'a> {
|
|||||||
///
|
///
|
||||||
/// This is useful if you don't want to repeat the same `active_class` prop value in every Link.
|
/// This is useful if you don't want to repeat the same `active_class` prop value in every Link.
|
||||||
/// By default set to `"active"`.
|
/// By default set to `"active"`.
|
||||||
#[props(default, strip_option)]
|
|
||||||
pub active_class: Option<&'a str>,
|
pub active_class: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user