Type Definition dioxus_core::Component

source ·
pub type Component<P = ()> = fn(_: Scope<'_, P>) -> Element<'_>;
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 {}
)