diff --git a/src/utils/ObjectUtils.ts b/src/utils/ObjectUtils.ts index 3477671..d52015f 100644 --- a/src/utils/ObjectUtils.ts +++ b/src/utils/ObjectUtils.ts @@ -68,6 +68,8 @@ export function shallowEqual(obj1: any, obj2: any): Boolean { // While this technically means this is deep equality for Immutables, // it's better to have a more specific check than an entirely incorrect one. if ( + obj1 && + obj2 && typeof obj1.hashCode === 'function' && typeof obj2.hashCode === 'function' ) { diff --git a/src/utils/__tests__/ObjectUtils-test.js b/src/utils/__tests__/ObjectUtils-test.js index f877189..b519ba8 100644 --- a/src/utils/__tests__/ObjectUtils-test.js +++ b/src/utils/__tests__/ObjectUtils-test.js @@ -109,5 +109,9 @@ describe('ObjectUtils', () => { // force hash collision - should fall back to .equals expect(shallowEqual(mockImmutable1, mockImmutable2)).toBe(false); }); + + it('handles immutable values if one input is falsy', () => { + expect(() => shallowEqual(Map({ a: 1 }), null)).not.toThrow(); + }); }); });