pub trait ComponentFunction<Props, Marker = ()>: Clone + 'static {
// Required method
fn rebuild(&self, props: Props) -> Result<VNode, RenderError>;
// Provided method
fn id(&self) -> TypeId { ... }
}
Expand description
Any component that implements the ComponentFn
trait can be used as a component.
This trait is automatically implemented for functions that are in one of the following forms:
fn() -> Element
fn(props: Properties) -> Element
You can derive it automatically for any function with arguments that implement PartialEq with the #[component]
attribute:
#[component]
fn MyComponent(a: u32, b: u32) -> Element {
rsx! { "a: {a}, b: {b}" }
}
Required Methods§
sourcefn rebuild(&self, props: Props) -> Result<VNode, RenderError>
fn rebuild(&self, props: Props) -> Result<VNode, RenderError>
Convert the component to a function that takes props and returns an element.
Provided Methods§
Object Safety§
This trait is not object safe.
Implementors§
impl<F> ComponentFunction<(), EmptyMarker> for F
impl<F, P> ComponentFunction<P> for F
Accept any callbacks that take props