Muhammad Hamza 5e823e729d
Prepare for 0.21 release (#3412)
* Update CHANGELOG

Changelog run: https://github.com/yewstack/yew/actions/runs/6283917852/job/17064800916

* docusaurus docs:version 0.21

* migration guide

* blog post

* prettier

* make website warnings go away

* make GA work

* Apply suggestions from code review

* Apply suggestion from review

Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com>

* prettier

---------

Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com>
2023-09-29 19:10:07 +09:00

27 lines
1.8 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] | `T` | got set | component instance |
| [use_state_eq] | `T: PartialEq` | got set with diff. value | component instance |
| [use_reducer] | `T: Reducible` | got reduced | component instance |
| [use_reducer_eq] | `T: Reducible + PartialEq` | got reduced with diff. value | component instance |
| [use_memo] | `Deps -> T` | dependencies changed | component instance |
| [use_callback] | `Deps -> Callback<E>` | dependencies changed | component instance |
| [use_mut_ref] | `T` | - | component instance |
| a static global variable | `T` | - | global, used by all |
[use_state]: https://yew-rs-api.web.app/next/yew/functional/fn.use_state.html
[use_state_eq]: https://yew-rs-api.web.app/next/yew/functional/fn.use_state_eq.html
[use_reducer]: https://yew-rs-api.web.app/next/yew/functional/fn.use_reducer.html
[use_reducer_eq]: https://yew-rs-api.web.app/next/yew/functional/fn.use_reducer_eq.html
[use_memo]: https://yew-rs-api.web.app/next/yew/functional/fn.use_memo.html
[use_callback]: https://yew-rs-api.web.app/next/yew/functional/fn.use_callback.html
[use_mut_ref]: https://yew-rs-api.web.app/next/yew/functional/fn.use_mut_ref.html