#[component]Expand description
Macro #[component] write component for rsx! like default Rust function
Name of the component must be in PascalCase
§Examples
§Declaration
use cercis::prelude::*;
#[component]
fn MyComponent() -> Element {
rsx!(h1 { "My component!" })
}§Props
use cercis::prelude::*;
#[component]
fn MyComponent<'a>(text: &'a str) -> Element {
rsx!(div {
h1 { "My component!" }
p { "{text}" }
})
}§Optional props
use cercis::prelude::*;
#[component]
fn MyComponent<'a>(text: Option<&'a str>) -> Element {
let text = text.unwrap_or("empty");
rsx!(div {
h1 { "My component!" }
p { "{text}" }
})
}