# hooks

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-view/hooks/

**module** · [`ferroui-view`](/docs/0.5.0/api/ferroui-view/) · v0.5.0

```rust
module hooks
```

Hooks: the state of a component that runs again.

A component made with `rerender` or
`#[component(rerender)]` runs its function again whenever a signal it read
while it ran changes, or its parent runs again; the elements it returns are
compared with those of the run before and the controls are patched
(`docs/declarative-ui.md`, section 8). What has to outlive one run is kept
in hooks: each `use_*` call has a slot of the component, found by the order
of the calls, so a hook is called on every run, in the same order, never in
a condition or a loop whose length changes.

- [`use_hook`](/docs/0.5.0/api/ferroui-view/hooks/function-use_hook/): a value made on the first run and handed back on the next
  ones.
- [`use_signal`](/docs/0.5.0/api/ferroui-view/hooks/function-use_signal/): a signal kept across runs. Reading it in the function
  makes the component run again when it changes; reading it in a property
  (`text: count`) changes only that property.
- [`use_memo`](/docs/0.5.0/api/ferroui-view/hooks/function-use_memo/): a memo kept across runs.
- [`use_effect`](/docs/0.5.0/api/ferroui-view/hooks/function-use_effect/): an effect started once the first run's controls are in
  place, which runs again when the signals it read change.
- [`use_effect_with`](/docs/0.5.0/api/ferroui-view/hooks/function-use_effect_with/): a closure run once the controls are in place, and
  again on a run whose dependencies differ; what it registered with
  `on_cleanup` runs before the next call and when the
  component is taken out.
- `use_future` (`async_data.rs`): a future started
  once the controls are in place and again on a run whose dependencies
  differ, and its state as a signal.

Everything a hook makes belongs to the component and is disposed when the
component is taken out. Signals made with `signal` in the
function itself belong to that run and are made again on the next one.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/hooks.rs#L1)

## Contents

- [`use_hook`](/docs/0.5.0/api/ferroui-view/hooks/function-use_hook/) — function
- [`use_signal`](/docs/0.5.0/api/ferroui-view/hooks/function-use_signal/) — function
- [`use_memo`](/docs/0.5.0/api/ferroui-view/hooks/function-use_memo/) — function
- [`use_effect`](/docs/0.5.0/api/ferroui-view/hooks/function-use_effect/) — function
- [`use_effect_with`](/docs/0.5.0/api/ferroui-view/hooks/function-use_effect_with/) — function
- [`use_parent_control`](/docs/0.5.0/api/ferroui-view/hooks/function-use_parent_control/) — function
- [`use_parent_property`](/docs/0.5.0/api/ferroui-view/hooks/function-use_parent_property/) — function
- [`use_data_context_value`](/docs/0.5.0/api/ferroui-view/hooks/function-use_data_context_value/) — function
- [`use_theme_variant`](/docs/0.5.0/api/ferroui-view/hooks/function-use_theme_variant/) — function
- [`use_resource`](/docs/0.5.0/api/ferroui-view/hooks/function-use_resource/) — function
- [`use_data_context`](/docs/0.5.0/api/ferroui-view/hooks/function-use_data_context/) — function
- [`use_resource_as`](/docs/0.5.0/api/ferroui-view/hooks/function-use_resource_as/) — function

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
