mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-16 13:48:13 +00:00
docs: warn that useState
should only contain JSON-serializable content (#5994)
Co-authored-by: pooya parsa <pyapar@gmail.com> Co-authored-by: Damian Głowala <48835293+DamianGlowala@users.noreply.github.com> Co-authored-by: Alwin Lohrie <46248939+niwla23@users.noreply.github.com>
This commit is contained in:
parent
92269dde44
commit
d77b62d63e
@ -10,6 +10,9 @@ Nuxt provides `useState` composable to create a reactive and SSR-friendly shared
|
||||
::alert{icon=👉}
|
||||
`useState` only works during `setup` or [`Lifecycle Hooks`](https://vuejs.org/api/composition-api-lifecycle.html#composition-api-lifecycle-hooks).
|
||||
::
|
||||
::alert{type=warning}
|
||||
Because the data inside `useState` will be serialized to JSON, it is important that it does not contain anything that cannot be serialized, such as classes, functions or symbols.
|
||||
::
|
||||
|
||||
## Best practices
|
||||
|
||||
|
@ -9,5 +9,9 @@ useState<T>(key: string, init?: () => T | Ref<T>): Ref<T>
|
||||
* **init**: A function that provides initial value for the state when not initiated. This function can also return a `Ref`.
|
||||
* **T**: (typescript only) Specify the type of state
|
||||
|
||||
::alert{type=warning}
|
||||
Because the data inside `useState` will be serialized to JSON, it is important that it does not contain anything that cannot be serialized, such as classes, functions or symbols.
|
||||
::
|
||||
|
||||
::ReadMore{link="/guide/features/state-management"}
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user