nuxt-community / universal-storage-module

Universal Storage Utilities for Nuxt 2
MIT License
276 stars 15 forks source link

Generate mode local state issue #76

Closed bdrtsky closed 4 years ago

bdrtsky commented 4 years ago

Fixes https://github.com/nuxt-community/universal-storage-module/issues/75

getState is always return undefined in development. And when running in prod in generate mode, getState returns initialState instead of actual saved local state in cookies or local storage (module ignores cookie or storage since getState return an actual value), which leads to overwriting of local session state.

farzadso commented 4 years ago

Looks good to me with the last commit @pi0

Any other pointers?

Atinux commented 4 years ago

~After talking with @pi0, we will put this PR in pending state until the target PR on Nuxt.js will be merged.~

Let's merge with only process.static check at the moment.

Atinux commented 4 years ago

A ctually it won't completely fixes #75 since it will have the hydration error but at least it gives the opportunity in a Nuxt plugin (user side) to change the HTML (thinking of @nuxt/theme) to avoid hydration error

bdrtsky commented 4 years ago

@Atinux so, then probably best not to update module for SSG usage and leave it as is? If so, please close this.

pi0 commented 4 years ago

@bdrtsky I think not for theme case but it fixes the bug of overriding with the initial state :+1: so if a state is used for client-only, universal-storage still has partial support. The point with dev check is that after static-target, users will be at least aware of behavior differences from development time :)