yew-autoprops

Crates.ioyew-autoprops
lib.rsyew-autoprops
version0.4.1
sourcesrc
created_at2023-05-21 20:16:06.571576
updated_at2023-12-04 15:36:51.042383
descriptionproc-macro to automatically derive Properties structs from args for Yew components
homepagehttps://github.com/yewstack/yew-autoprops
repositoryhttps://github.com/yewstack/yew-autoprops
max_upload_size
id870139
size32,412
Elina (ranile)

documentation

https://docs.rs/yew-autoprops/

README

yew-autoprops

Crate Info API Docs

proc-macro to automatically derive Properties structs from args for Yew components

No more extra one-off Props structs!

Examples

use yew_autoprops::autoprops;
use yew::prelude::*;

#[autoprops]
#[function_component]
fn CoolComponent(#[prop_or_default] hidden: bool, smth: &AttrValue) -> Html {
    html! {
        <div class={classes!(hidden.then_some("hidden"))}>
            <p>{ smth }</p>
        </div>
    }
}
use yew_autoprops::autoprops;
use yew::prelude::*;

#[autoprops(CoolComponentProps)]
#[function_component(CoolComponent)]
fn cool_component(#[prop_or_default] hidden: bool, smth: &AttrValue) -> Html {
    html! {
        <div class={classes!(hidden.then_some("hidden"))}>
            <p>{ smth }</p>
        </div>
    }
}
Commit count: 36

cargo fmt