useCookie does share state between layout and component when used in composable
First of all, here is a reproduction: https://stackblitz.com/edit/nuxt-starter-agstq6
It looks like
The
When i call the state change function from the layout, watch functions in the same layout will trigger.
When i call the state change function from another component, the layout is not aware of the changed state of
When i saw correctly, there is a closed issue on github regarding it: https://github.com/nuxt/nuxt/issues/13020 including a PR https://github.com/nuxt/nuxt/pull/20970 from June 23 to fix this. But using
It looks like
useCookie does not share the state like useState would between vue components.The
useCookie is used within a composable and have a simple function to change the state on button click.When i call the state change function from the layout, watch functions in the same layout will trigger.
When i call the state change function from another component, the layout is not aware of the changed state of
useCookieWhen i saw correctly, there is a closed issue on github regarding it: https://github.com/nuxt/nuxt/issues/13020 including a PR https://github.com/nuxt/nuxt/pull/20970 from June 23 to fix this. But using
Nuxt v3.12.2 this bug appears again.StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
GitHub
Environment 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 <templat...
GitHub
Linked issue
resolves #13020
Type of change
Documentation (updates to the documentation, readme or JSdoc annotations)
Bug fix (a non-breaking change that fixes an issue)
Enhancement...
resolves #13020