Crate dioxus_hooks

source ·
Expand description

Dioxus Hooks

Crates.io MIT licensed Build Status Discord chat

Website | Guides | API Docs | Chat

Overview

dioxus-hooks includes some basic useful hooks for dioxus:

  • use_state
  • use_ref
  • use_future
  • use_coroutine
  • use_callback

Unlike React, none of these hooks are foundational since they all build off the primitive cx.use_hook.

This crate also provides a few helpful macros to get around some Rust lifetime management issues in async.

  • to_owned![]
  • use_future!()
  • use_callback!()

Contributing

  • Report issues on our issue tracker.
  • Join the discord and ask questions!

License

This project is licensed under the MIT license.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Dioxus by you shall be licensed as MIT without any additional terms or conditions.

Modules

Macros

Structs

  • An error returned by [RefCell::try_borrow].
  • An error returned by [RefCell::try_borrow_mut].
  • Wraps a borrowed reference to a value in a RefCell box. A wrapper type for an immutably borrowed value from a RefCell<T>.
  • A clone of the standard library’s RefCell type.
  • A wrapper type for a mutably borrowed value from a RefCell<T>.
  • The receiving end of an unbounded mpsc channel.
  • The transmission end of an unbounded mpsc channel.
  • A type created by the use_ref hook. See its documentation for more details.
  • State that is shared between components through the context system

Enums

Traits

Functions

  • Consume some context in the tree, providing a sharable handle to the value
  • Provide some context via the tree and return a reference to it
  • Maintain a handle over a future that can be paused, resumed, and canceled.
  • Get a handle to a coroutine higher in the tree
  • A hook that provides a future that executes after the hooks have been applied.
  • A future that resolves to a value.
  • A hook that provides a callback that executes if the dependencies change. This is useful to avoid running computation-expensive calculations even when the data doesn’t change.
  • A hook that runs a future when the component is mounted.
  • Creates a callback that will be run before the component is removed. This can be used to clean up side effects from the component (created with use_effect).
  • use_on_unmountDeprecated
  • use_ref is a key foundational hook for storing state in Dioxus.
  • This hook provides some relatively light ergonomics around shared state.
  • Provide some state for components down the hierarchy to consume without having to drill props. See use_shared_state to consume the state
  • Store state between component renders.