Open kirillsemyonkin opened 1 year ago
As of writing, yew-autoprops does not support pattern-binding the props using the built-in @ operator (syntactically correct without the #[autoprops_component]):
yew-autoprops
@
#[autoprops_component]
#[derive(PartialEq)] pub struct ExampleProp { i: u64, } #[autoprops_component] pub fn Example(example_prop @ ExampleProp { i }: &ExampleProp) -> Html { html! { } } #[function_component] pub fn App() -> Html { html! { <Example example_prop={ ExampleProp { i: 0 } } /> } }
Errors:
expected `:`, found `@` the trait bound `ExampleProps: Properties` is not satisfied no field `example_prop` on type `ExampleProps`
Handle pattern after the @ operator.
#[derive(PartialEq)] pub struct ExampleProp { i: u64, } #[derive(PartialEq, Properties)] pub struct ExampleProps { example_prop: ExampleProp, } #[function_component] pub fn Example( ExampleProps { // without the `example_prop @` the `example_prop` name will not be accessible in the function body example_prop: example_prop @ ExampleProp { i }, }: &ExampleProps, ) -> Html { html! { } } #[function_component] pub fn App() -> Html { html! { <Example example_prop={ ExampleProp { i: 0 } } /> } }
As of writing,
yew-autoprops
does not support pattern-binding the props using the built-in@
operator (syntactically correct without the#[autoprops_component]
):Errors:
Possible Solution
Handle pattern after the
@
operator.