From a2825fb13ce62e6750f920b81e9a26721033433f Mon Sep 17 00:00:00 2001 From: Maccesch Date: Wed, 16 Mar 2022 06:36:39 +0000 Subject: [PATCH] updated examples with the new optional props --- examples/optional_props.rs | 21 +++++++++++---------- packages/router/src/components/redirect.rs | 1 - packages/router/src/components/router.rs | 2 -- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/examples/optional_props.rs b/examples/optional_props.rs index 9485a2aeb..3c47b3aac 100644 --- a/examples/optional_props.rs +++ b/examples/optional_props.rs @@ -14,37 +14,38 @@ fn app(cx: Scope) -> Element { cx.render(rsx! { Button { a: "asd".to_string(), - c: Some("asd".to_string()), - d: "asd".to_string(), + c: "asd".to_string(), + d: Some("asd".to_string()), e: "asd".to_string(), } }) } +type SthElse = Option; + #[derive(Props, PartialEq)] struct ButtonProps { a: String, #[props(default)] - b: Option, + b: String, - #[props(default)] c: Option, - #[props(default, strip_option)] + #[props(!optional)] d: Option, #[props(optional)] - e: Option, + e: SthElse, } fn Button(cx: Scope) -> Element { cx.render(rsx! { button { - "{cx.props.a}" - "{cx.props.b:?}" - "{cx.props.c:?}" - "{cx.props.d:?}" + "{cx.props.a} | " + "{cx.props.b:?} | " + "{cx.props.c:?} | " + "{cx.props.d:?} | " "{cx.props.e:?}" } }) diff --git a/packages/router/src/components/redirect.rs b/packages/router/src/components/redirect.rs index a1d2d7727..7a7d85be2 100644 --- a/packages/router/src/components/redirect.rs +++ b/packages/router/src/components/redirect.rs @@ -27,7 +27,6 @@ pub struct RedirectProps<'a> { /// // Relative path /// Redirect { from: "", to: "../" } /// ``` - #[props(optional)] pub from: Option<&'a str>, } diff --git a/packages/router/src/components/router.rs b/packages/router/src/components/router.rs index d7df377f1..85adfa422 100644 --- a/packages/router/src/components/router.rs +++ b/packages/router/src/components/router.rs @@ -20,7 +20,6 @@ pub struct RouterProps<'a> { /// /// This will be used to trim any latent segments from the URL when your app is /// not deployed to the root of the domain. - #[props(optional)] pub base_url: Option<&'a str>, /// 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. /// By default set to `"active"`. - #[props(default, strip_option)] pub active_class: Option<&'a str>, }