Skip to content

Commit

Permalink
fix: 修复react key为null时diff错误
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed Oct 29, 2021
1 parent 31f0a35 commit 5c9c8ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/f2-next/src/children.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray } from '@antv/util';
import { isArray, isNil } from '@antv/util';
import { map } from './util';

function cloneElement(element, props) {
Expand All @@ -22,7 +22,7 @@ function compareArray(
const lastLength = lastElements.length;
for (let i = 0, len = lastLength; i < len; i++) {
const element = lastElements[i];
if (element && element.key !== undefined) {
if (element && !isNil(element.key)) {
const { key } = element;
keyed[key] = element;
}
Expand All @@ -37,7 +37,7 @@ function compareArray(
}
const { key } = element;
// 有key值定义
if (key !== undefined) {
if (!isNil(element.key)) {
const lastElement = keyed[key];
if (lastElement) delete keyed[key];
compare(element, lastElement, callback);
Expand Down
17 changes: 13 additions & 4 deletions packages/f2-next/src/components/line/lineView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ export default (props: any) => {
{dataArray.map((data) => (
<polyline
attrs={{
points: data,
stroke: color,
lineWidth:size,
...shape
points: data.map((item) => {
return { x: item.x, y: item.y };
}),
stroke: color,
lineWidth: size,
...shape,
}}
animation={{
update: {
easing: 'linear',
duration: 450,
property: ['points'],
},
}}
/>
))}
Expand Down

0 comments on commit 5c9c8ad

Please sign in to comment.