Module yew::functional[][src]

Expand description

Function components are a simplified version of normal components. They consist of a single function annotated with the attribute #[function_component(_)] that receives props and determines what should be rendered by returning Html.

#[function_component(HelloWorld)]
fn hello_world() -> Html {
    html! { "Hello world" }
}

More details about function components and Hooks can be found on Yew Docs

Structs

Wrapper that allows a struct implementing FunctionProvider to be consumed as a component.

The HookUpdater provides a convenient interface for hooking into the lifecycle of the underlying Yew Component that backs the function component.

Dispatcher handle for use_reducer and use_reducer_eq hook

State handle for use_reducer and use_reducer_eq hook

State handle for the use_state hook.

Setter handle for use_state and use_state_eq hook

Traits

Trait that allows a struct to act as Function Component.

A trait that implements a reducer function of a type.

Functions

Hook for consuming context values in function components. The context of the type passed as T is returned. If there is no such context in scope, None is returned. A component which calls use_context will re-render when the data of the context changes.

This hook is used for hooking into the component’s lifecycle.

This hook is similar to use_effect but it accepts dependencies.

Low level building block of creating hooks.

This hook is used for obtaining a mutable reference to a stateful value. Its state persists across renders.

This hook is used for obtaining a NodeRef. It persists across renders.

This hook is an alternative to use_state. It is used to handle component’s state and is used when complex actions needs to be performed on said state.

use_reducer but only re-renders when prev_state != next_state.

This hook is used for obtaining a immutable reference to a stateful value. Its state persists across renders.

This hook is used to manage state in a function component.

use_state but only re-renders when prev_state != next_state.

Attribute Macros

This attribute creates a function component from a normal Rust function.