Props struct is not supplied with the generic clause, so it does not know about the type T.
Possible solution
This appears to be solvable by copying the generic clause (<T: PartialEq + 'static>) over to both generated component fn (as-is) and generated Props struct (if individual generic parameters are used); as well as copying the clause to the component fn Props param's type, modified to contain only the type names (<T>).
Example 1:
#[derive(PartialEq, Properties)]
pub struct ExampleProps {
// alternatively, `pub struct ExampleProps<T: PartialEq + 'static>`,
// but then it would need `#[prop_or_default] pub T: PhantomData<T>` as a hack
}
#[function_component]
pub fn Example<T: PartialEq + 'static>(ExampleProps {}: &ExampleProps) -> Html {
html! {
}
}
#[function_component]
pub fn App() -> Html {
html! {
<Example<u64> />
}
}
As of writing the issue,
yew-autoprops
does not support generics.Example 1:
Errors:
Probable reasons:
Example 2:
Errors:
Probable reasons:
T
.Possible solution
This appears to be solvable by copying the generic clause (
<T: PartialEq + 'static>
) over to both generated componentfn
(as-is) and generated Propsstruct
(if individual generic parameters are used); as well as copying the clause to the componentfn
Props param's type, modified to contain only the type names (<T>
).Example 1:
Example 2: