`useCookie` state is stored independently
See original GitHub issueEnvironment
- Operating System:
Darwin
- Node Version:
v14.17.3
- Nuxt Version:
3.0.0
- Package Manager:
yarn@3.1.1
- Bundler:
Vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
<template>
<div>
<h1>
{{ cookie2 }}
</h1>
<button @click="cookie1 = (Math.random() * 100).toFixed()">
Change cookie
</button>
</div>
</template>
<script setup>
const cookie1 = useCookie('test')
const cookie2 = useCookie('test')
</script>
Describe the bug
Multiple invocations of useCookie
are not synced, and so setting one will not trigger a change to others. This is not a bug per-se, but it’s inconsistent compared to useState
, for example…
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:16 (9 by maintainers)
Top Results From Across the Web
Store state in cookies with use-cookie-state React hook
Store state in cookies with use-cookie-state React hook ... Sometimes it becomes necessary to keep the state of the application between reloads ...
Read more >Cookies vs. sessions - Stack Overflow
The concept is storing persistent data across page loads for a web visitor. Cookies store it directly on the client. Sessions use a...
Read more >Cookie Store API - GitHub Pages
Cookie Store. A cookie store is normatively defined for user agents by Cookies: HTTP State Management Mechanism §User Agent Requirements. When ...
Read more >How To Manage State with Hooks on React Components
Each of these can be stored in state using the above Hook. ... With Hooks, state objects are completely independent of each other, ......
Read more >IIE Website Cookie Policy - Institute of International Education
We use cookie technology on our Website, which allows us to ... you do not want cookies to be stored, you may turn...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is the composable I created:
Would be awesome to have
useCookie
behave similarly touseState
but persisted in cookies