mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
* Read through the docs and correct spelling and grammar * Run prettier * Apply review suggestions Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com> * adjust translation messages Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
19 lines
1.5 KiB
Plaintext
19 lines
1.5 KiB
Plaintext
---
|
|
title: 'State'
|
|
---
|
|
|
|
## General view of how to store state
|
|
|
|
This table can be used as a guide when deciding what state storing type fits best for your use case:
|
|
|
|
| Hook | Type | Rerender when? | Scope |
|
|
| ---------------------------------------------------- | -------------------------- | ---------------------------- | ------------------- |
|
|
| [use_state](./hooks/use-state) | `T` | got set | component instance |
|
|
| [use_state_eq](./hooks/use-state#use_state_eq) | `T: PartialEq` | got set with diff. value | component instance |
|
|
| [use_reducer](./hooks/use-reducer) | `T: Reducible` | got reduced | component instance |
|
|
| [use_reducer_eq](./hooks/use-reducer#use_reducer_eq) | `T: Reducible + PartialEq` | got reduced with diff. value | component instance |
|
|
| [use_memo](./hooks/use-memo) | `Deps -> T` | dependencies changed | component instance |
|
|
| [use_callback](./hooks/use-callback) | `Deps -> Callback<E>` | dependencies changed | component instance |
|
|
| [use_mut_ref](./hooks/use-mut-ref) | `T` | - | component instance |
|
|
| a static global variable | `T` | - | global, used by all |
|