Skip to content

Commit

Permalink
fix: Fix hydration issues (#266)
Browse files Browse the repository at this point in the history
* fix(timer): Revert lazy loading timer styles

* fix(store-persist): Only restore state when mounted
  • Loading branch information
Hanziness authored Sep 2, 2022
1 parent 1ee7b68 commit 419293c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions components/timer/display/_timerSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ import { AvailableTimers } from '~~/stores/settings'
import TimerMixin from '@/assets/mixins/timerMixin'
import { useSchedule, TimerState } from '~~/stores/schedule'
import TimerTraditional from '@/components/timer/display/timerTraditional.vue'
import TimerApproximate from '@/components/timer/display/timerApproximate.vue'
import TimerPercentage from '@/components/timer/display/timerPercentage.vue'
import CompleteMarker from '@/components/timer/display/timerComplete.vue'
export default {
components: {
TimerTraditional: defineAsyncComponent(() => import('@/components/timer/display/timerTraditional.vue')),
TimerApproximate: defineAsyncComponent(() => import('@/components/timer/display/timerApproximate.vue')),
TimerPercentage: defineAsyncComponent(() => import('@/components/timer/display/timerPercentage.vue')),
CompleteMarker: defineAsyncComponent(() => import('@/components/timer/display/timerComplete.vue'))
TimerTraditional,
TimerApproximate,
TimerPercentage,
CompleteMarker
},
mixins: [TimerMixin],
props: {
Expand Down
4 changes: 3 additions & 1 deletion plugins/store-persist.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function restoreStore (store) {
const stateToRestore = JSON.parse(localStorage.getItem(getStorePersistenceKey(store.$id)))

if (stateToRestore !== null) {
store.$patch(stateToRestore)
onMounted(() => {
store.$patch(stateToRestore)
})

console.log(`Restoring ${store.$id}`)
const mainStore = useMain()
Expand Down

0 comments on commit 419293c

Please sign in to comment.