Type Alias freya::prelude::Component

pub type Component<P = ()> = Rc<dyn Fn(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: Props) -> Element {
    // ...
}

rsx!(
    example()
)

React-Style

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

rsx!(
    Example {}
)

Aliased Type§

struct Component<P = ()> { /* private fields */ }