mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
fix(shallow): undefined value (#3205)
* add failing test * check with .has
This commit is contained in:
parent
c4085a4ff0
commit
2cc19881fa
@ -19,7 +19,7 @@ const compareEntries = (
|
||||
return false
|
||||
}
|
||||
for (const [key, value] of mapA) {
|
||||
if (!Object.is(value, mapB.get(key))) {
|
||||
if (!mapB.has(key) || !Object.is(value, mapB.get(key))) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,6 +170,10 @@ describe('shallow', () => {
|
||||
const arr = [1, 2]
|
||||
expect(shallow([arr, 1], [arr, 1])).toBe(true)
|
||||
})
|
||||
|
||||
it('should work with undefined (#3204)', () => {
|
||||
expect(shallow({ a: undefined }, { b: 1 })).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('mixed cases', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user