yewstack / yew-autoprops

Apache License 2.0
8 stars 1 forks source link

Propless generic components require generic types to be used #7

Closed kirillsemyonkin closed 10 months ago

kirillsemyonkin commented 12 months ago

Imagine a component like so:

#[autoprops_component]
pub fn Example<T: 'static>() -> Html {
    html! {}
}

As T is not used, Rust complains:

parameter `T` is never used
consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`

At least, currently solvable with following code:

#[autoprops_component]
pub fn Example<T: 'static>(#[prop_or_default] _never: &PhantomData<T>) -> Html {
    html! {}
}
cecton commented 11 months ago

Fixed in my port of yew-autoprops to Yew