Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nitedani committed Jul 7, 2024
1 parent b5c1615 commit 0f94f41
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/vike-react-zustand/src/renderer/Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep, mergeWith } from 'lodash-es'
import { mergeWith } from 'lodash-es'
import React, { ReactNode, useMemo } from 'react'
import { usePageContext } from 'vike-react/usePageContext'
import { create as createZustand } from 'zustand'
Expand Down Expand Up @@ -42,10 +42,10 @@ export default function Wrapper({ children }: { children: ReactNode }) {
} else if (pageContext._vikeReactZustand && !store.__hydrated__ && !pageContext.isClientSideNavigation) {
assert(key in pageContext._vikeReactZustand)

// TODO: remove lodash-es dependency and implement deep merging
const merged = mergeWith(cloneDeep(store.getInitialState()), pageContext._vikeReactZustand[key])
//@ts-ignore
Object.assign(store.getInitialState(), merged)
const initialStateClient = store.getInitialState()
const initialStateServer = pageContext._vikeReactZustand[key]
mergeWith(initialStateClient, initialStateServer)

store.__hydrated__ = true
}
}
Expand Down

0 comments on commit 0f94f41

Please sign in to comment.