mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-27 06:30:20 +00:00
tweaks
This commit is contained in:
parent
e413ea4019
commit
bf0247a7dc
1 changed files with 7 additions and 4 deletions
|
@ -2,11 +2,14 @@
|
|||
|
||||
[`use_effect`](https://docs.rs/dioxus-hooks/latest/dioxus_hooks/fn.use_effect.html) provides a future that executes after the hooks have been applied.
|
||||
|
||||
Whenever the hooks dependencies change, the future will be re-evaluated. This is useful to syncrhonize with external events.
|
||||
Whenever the hooks [dependencies](#dependencies) change, the future will be re-evaluated. This is useful to syncrhonize with external events.
|
||||
|
||||
If a future is pending when the dependencies change, the previous future will be allowed to continue
|
||||
|
||||
> The `dependencies` is tuple of references to values that are `PartialEq + Clone`.
|
||||
## Dependencies
|
||||
|
||||
You might want to call `use_effect` only when some value changes. For example, you might want to fetch a user's data only when the user id changes. You can provide a tuple of "dependencies" to the hook. It will automatically re-run the future when any of those dependencies change.
|
||||
|
||||
Example:
|
||||
|
||||
```rust, no_run
|
||||
#[inline_props]
|
||||
|
@ -29,4 +32,4 @@ fn app(cx: Scope) -> Element {
|
|||
Profile { id: "dioxusLabs" }
|
||||
)
|
||||
}
|
||||
```
|
||||
```
|
Loading…
Reference in a new issue