Skip to content

SSR Hydration with Computed property #2554

Closed Answered by posva
Vap0r1ze asked this question in Help and Questions
Discussion options

You must be logged in to vote

you can only skipHydrate on state, so no need to use it in isDark
prefersDark is state you need to return it and it should also skipHydrate since the state comes from the client
There is no onMounted() in stores, that's a component lifecycle method
so just use if (typeof document !== 'undefined') change prefers dark

Here is the fixed version: https://play.pinia.vuejs.org/#eNqVVVtv0zAU/ismDzSV2mRjMKStLeUyCRADxPaYlyw5Tb06tmU7baeu/51jO0mTscF4qnMu3/nOtbvgvZTRuoLgLJjoTFFpiAZTScJSXkyTwOgkmCWcllIoQ3ak0nC9hBKujFBA9mShREkGUWysMDJ6kPCEZ4JrQ5yITPsu4TDhk9hHQlz8MFBKlhrAL0ImN5UxgpN5xmi2svE9rigKZn2D2bV7evBJ7M29q5y5MGdkt/PqyDPY7yexRJNJ3IYKRoHPaFymMrrVgmP+O4uS1ApMG4GsxMok5TS1kiSI3TsCXY5vlNhoUOifBKPGdI7FxI…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants