#[component]Expand description
Component attribute macro for defining reusable components
Transforms a function into a component with automatic prop handling.
The first parameter must be cx: &Arc<Context>.
Remaining parameters become component props.
§Example
ⓘ
#[component]
pub fn Counter(cx: &Arc<Context>, initial: &i32) -> View {
let count = use_state(*initial);
Arc::new(move |ctx| {
ctx.draw_text(Point { x: 0, y: 0 }, &format!("Count: {}", count.get_dl()));
})
}