Skip to content

Commit c690260

Browse files
committed
omit itemKey
1 parent 9b33d2c commit c690260

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/List.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class List<T> extends React.Component<ListProps<T>, ListState> {
6868
* Phase 4: Record used item height
6969
* Phase 5: Trigger re-render to use correct position
7070
*/
71-
public componentDidUpdate() {
71+
public componentDidUpdate(prevProps: ListProps<T>) {
7272
const { status, startIndex, endIndex } = this.state;
7373
const { dataSource, itemKey } = this.props;
7474

@@ -82,6 +82,11 @@ class List<T> extends React.Component<ListProps<T>, ListState> {
8282

8383
this.setState({ status: 'MEASURE_DONE' });
8484
}
85+
86+
// Re-calculate the scroll position align with the current visible item position
87+
if (prevProps.dataSource.length !== dataSource.length) {
88+
console.log('!!!!!!');
89+
}
8590
}
8691

8792
public getItemHeight = (index: number) => this.itemElementHeights[index] || 0;
@@ -147,6 +152,7 @@ class List<T> extends React.Component<ListProps<T>, ListState> {
147152
itemHeight,
148153
dataSource,
149154
children,
155+
itemKey,
150156
...restProps
151157
} = this.props;
152158

0 commit comments

Comments
 (0)