mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
docs: note that useCookie
does not share state (#20665)
This commit is contained in:
parent
0508ec2b3e
commit
c543ea8244
@ -18,6 +18,10 @@ const cookie = useCookie(name, options)
|
|||||||
`useCookie` ref will automatically serialize and deserialize cookie value to JSON.
|
`useCookie` ref will automatically serialize and deserialize cookie value to JSON.
|
||||||
::
|
::
|
||||||
|
|
||||||
|
::alert{icon=⚠️}
|
||||||
|
Multiple invocations of `useCookie` with the same name are not synced. [You can utilise `useState()` to sync them as a workaround](https://github.com/nuxt/nuxt/issues/13020#issuecomment-1505548242).
|
||||||
|
::
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
The example below creates a cookie called `counter`. If the cookie doesn't exist, it is initially set to a random value. Whenever we update the `counter` variable, the cookie will be updated accordingly.
|
The example below creates a cookie called `counter`. If the cookie doesn't exist, it is initially set to a random value. Whenever we update the `counter` variable, the cookie will be updated accordingly.
|
||||||
|
Loading…
Reference in New Issue
Block a user