We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using useStorage for app state like this:
export const useOrder = () => useLocalStorage<Order>('order', { items: [] })
The SSR will render UI with default value and client will render UI with saved state which will render to Hydration node mismatch warning.
It would be nice if I can solve it like this:
export const useOrder = () => useLocalStorage<Order>('order', { items: [] }, { ssrUseDefault: true })
Which will set default value first and wait for page:finish hook.
Workaround:
export function useOrder () { const order = ref(defaultOrder) useNuxtApp().hook('page:finish', () => { const storedOrder = useLocalStorage<Order>('order', defaultOrder) order.value = storedOrder.value }) return order }
Maybe print warning when ssrUseDefault option was used in non-Nuxt environment.
The text was updated successfully, but these errors were encountered:
feat(useStorage): add waitOnMounted option for SSR
waitOnMounted
a84b5c3
Close vueuse#3447
A possible implementation would be to setup the listeners within onMounted() so they are only applied once the app has rendered. I opened #3504
onMounted()
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Clear and concise description of the problem
When using useStorage for app state like this:
The SSR will render UI with default value and client will render UI with saved state which will render to Hydration node mismatch warning.
Suggested solution
It would be nice if I can solve it like this:
Which will set default value first and wait for page:finish hook.
Alternative
Workaround:
Additional context
Maybe print warning when ssrUseDefault option was used in non-Nuxt environment.
Validations
The text was updated successfully, but these errors were encountered: