|
@@ -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" }
|
|
|
)
|
|
|
}
|
|
|
-```
|
|
|
+```
|