Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

docs: warn that useState should only contain JSON-serializable content #5994

Merged
merged 6 commits into from
Jul 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/content/3.api/1.composables/use-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ref `useState` creates will be persisted from server to client, it is important that it does not contain anything (on server side) that cannot be serialized to JSON, such as a class or function. Once loaded on the client, it behaves as a normal ref and does not have this limitation.
danielroe marked this conversation as resolved.
Show resolved Hide resolved
::

::ReadMore{link="/guide/features/state-management"}
::