SSR Hydration with Computed property #2554
-
The docs very briefly speak about the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
you can only skipHydrate on state, so no need to use it in BTW, I go through some of these advanced concepts in my course: https://masteringpinia.com/ |
Beta Was this translation helpful? Give feedback.
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 methodso 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…