docs: add rules of hooks

This commit is contained in:
Jonathan Kelley committed 2022-01-28 03:04:21 -05:00
1 parent 4fb2221ee1
commit 564284f4be
5 files changed
+113 -9

No files matched your search

@@ -0,0 +1,23 @@
# `use_state` and `use_ref`
Most components you will write in Dioxus will need to store state somehow. For local state, we provide two very convenient hooks:
- `use_state`
- `use_ref`
Both of these hooks are extremely powerful and flexible, so we've dedicated this section to understanding them properly.
## Note on Hooks
If you're struggling with errors due to usage in hooks, make sure you're following the rules of hooks:
## `use_state`
The `use_state` hook is very similar to its React counterpart.
## `use_ref`