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:
|
2021-12-15 20:56:53 +00:00
|
|
|
let value = use_state(&cx, || 10);
|
2021-07-09 15:54:07 +00:00
|
|
|
|
|
|
|
// "Classic" usage:
|
2021-12-15 20:56:53 +00:00
|
|
|
let (value, set_value) = use_state(&cx, || 0).split();
|
2021-07-09 15:54:07 +00:00
|
|
|
```
|