N
Nuxt6mo ago
Luigi

Problem with reactivity and cookies.

I want to build a currency selector for my website, where I currently only display prices in USD. I thought of making a currency selector that stores the selected currency as a cookie. I made a composable called usePrice and a <Price/> component that gets a value and reactivly update the displayed price. But the problem I have is, if I render the <Price/> component for example 10 times, only the last rendered component will reactivley change the displayed price when I change the currency. The other ones will not. Only if I hard refresh the site they will show the updated price too. I don't know where this problem comes from or if it has to do something with my logic. Here is screenshots of my code: 1. Currency Selector Component 2. usePrice composable 3. <Price/> component
No description
No description
No description
5 Replies
Reinier Kaper
Reinier Kaper6mo ago
This is a known issue and currently the only solution is to downgrade to 3.11.3: https://github.com/nuxt/nuxt/issues/27660
GitHub
Use useCookie to modify the value in one component, but the value i...
Environment Operating System: Windows_NT Node Version: v20.9.0 Nuxt Version: 3.12.2 CLI Version: 3.12.0 Nitro Version: 2.9.6 Package Manager: [email protected] Builder: - Reproduction When running on my d...
Luigi
LuigiOP6mo ago
Alright good to know, thanks!
bekhruz
bekhruz6mo ago
in nuxt.config.ts experimental: { cookieStore: false, }, helped to me reactivity is working
Reinier Kaper
Reinier Kaper6mo ago
I can confirm this works in the latest version of Nuxt 3 for us as well
Luigi
LuigiOP6mo ago
Yes, works for me too 👍
Want results from more Discord servers?
Add your server