Skip to content

Commit

Permalink
Ignore React nodes in isEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
albanqoku committed Nov 11, 2019
1 parent 3ffb3f8 commit 5b85b2a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isValidElement } from 'react'
import loadScript from 'load-script'
import merge from 'deepmerge'

Expand Down Expand Up @@ -144,12 +145,15 @@ export function isObject (val) {
return val !== null && typeof val === 'object'
}

// Deep comparison of two objects but ignoring
// functions, for use in shouldComponentUpdate
// Deep comparison of two objects, but ignoring functions
// and React elements, for use in shouldComponentUpdate
export function isEqual (a, b) {
if (typeof a === 'function' && typeof b === 'function') {
return true
}
if (isValidElement(a) && isValidElement(b)) {
return true
}
if (a instanceof Array && b instanceof Array) {
if (a.length !== b.length) {
return false
Expand Down

0 comments on commit 5b85b2a

Please sign in to comment.