dioxus/packages/hooks/README.md

23 lines
402 B
Markdown
Raw Normal View History

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