dioxus/packages/hooks/README.md

23 lines
402 B
Markdown
Raw Normal View History

2021-07-09 15:54:07 +00:00
# Common hooks for Dioxus
This crate includes some basic useful hooks for dioxus:
- use_state
- use_ref
2021-12-30 02:28:28 +00:00
- use_future
- use_coroutine
2021-07-09 15:54:07 +00:00
## use_state
2021-12-30 02:28:28 +00:00
The primary mechanism of stored state.
2021-07-09 15:54:07 +00:00
You can always use it "normally" with the `split` method:
```rust
2021-12-30 02:28:28 +00:00
// Rusty-smart-pointer usage:
let value = use_state(&cx, || 10);
2021-07-09 15:54:07 +00:00
// "Classic" usage:
let (value, set_value) = use_state(&cx, || 0).split();
2021-07-09 15:54:07 +00:00
```