Skip to content

Commit

Permalink
fix: check for deep equality for defaultValues
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed May 14, 2024
1 parent e7c5fef commit 0a35176
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/lib/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
applyDiffWithCreateQueriesFromPatch,
applyFlatConfigToState,
} from './utils.js'
import isDeepEqual from 'fast-deep-equal'

export enum HistoryEventType {
PUSH,
Expand Down Expand Up @@ -439,7 +440,7 @@ export const converter =
values: T[N]['values']
) => {
const current = get().namespaces[ns]
const defaultsEqual = current?.initialValues === initialValues
const defaultsEqual = isDeepEqual(current?.initialValues, initialValues)
if (current !== undefined) {
set(
(state) => {
Expand Down
8 changes: 5 additions & 3 deletions test.setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @ts-ignore
window.requestIdleCallback = jest.fn().mockImplementation((cb: () => unknown) => {
return setTimeout(cb, 15)
})
window.requestIdleCallback = jest
.fn()
.mockImplementation((cb: () => unknown) => {
return setTimeout(cb, 15)
})

0 comments on commit 0a35176

Please sign in to comment.