Type Definition freya::prelude::Component

pub type Component<P = ()> = fn(_: &Scoped<'_, P>) -> Option<VNode<'_>>;
Expand description

A Component is a function that takes a Scope and returns an Element.

Components can be used in other components with two syntax options:

  • lowercase as a function call with named arguments (rust style)
  • uppercase as an element (react style)

Rust-Style

fn example(cx: Scope<Props>) -> Element {
    // ...
}

rsx!(
    example()
)

React-Style

fn Example(cx: Scope<Props>) -> Element {
    // ...
}

rsx!(
    Example {}
)