-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
import { isObject, isArray } from '@antv/util'; | ||
|
||
const isEqual = (value: any, other: any): boolean => { | ||
if (isObject(value) && isObject(other)) { | ||
const valueKeys = Object.keys(value); | ||
const otherKeys = Object.keys(other); | ||
if (valueKeys.length !== otherKeys.length) { | ||
return false; | ||
} | ||
let rst = true; | ||
for (let i = 0; i < valueKeys.length; i++) { | ||
rst = isEqual(value[valueKeys[i]], other[valueKeys[i]]); | ||
if (!rst) { | ||
break; | ||
} | ||
} | ||
return rst; | ||
} | ||
if (isArray(value) && isArray(other)) { | ||
if (value.length !== other.length) { | ||
return false; | ||
} | ||
let rst = true; | ||
for (let i = 0; i < value.length; i++) { | ||
rst = isEqual(value[i], other[i]); | ||
if (!rst) { | ||
break; | ||
} | ||
} | ||
return rst; | ||
} | ||
if (value === other) { | ||
return true; | ||
} | ||
if (!value || !other) { | ||
return false; | ||
} | ||
return false; | ||
}; | ||
|
||
export default isEqual; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
直接对比引用就好了,如果使用测试数据 两次数据都一样, 明明setState更改了 data, 但是图表没有重绘。