Skip to content

Commit 9915070

Browse files
committed
fix: remove sharedConfig
1 parent 7c89792 commit 9915070

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

src/List.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import useOriginScroll from './hooks/useOriginScroll';
1818
import useScrollDrag from './hooks/useScrollDrag';
1919
import type { ScrollPos, ScrollTarget } from './hooks/useScrollTo';
2020
import useScrollTo from './hooks/useScrollTo';
21-
import type { ExtraRenderInfo, GetKey, RenderFunc, SharedConfig } from './interface';
21+
import type { ExtraRenderInfo, GetKey, RenderFunc } from './interface';
2222
import type { ScrollBarDirectionType, ScrollBarRef } from './ScrollBar';
2323
import ScrollBar from './ScrollBar';
2424
import { getSpinSize } from './utils/scrollbarUtil';
@@ -165,12 +165,6 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
165165
setScrollMoving(false);
166166
};
167167

168-
const sharedConfig: SharedConfig<T> = React.useMemo(() => {
169-
return {
170-
getKey,
171-
};
172-
}, [getKey]);
173-
174168
// ================================ Scroll ================================
175169
function syncScrollTop(newTop: number | ((prev: number) => number)) {
176170
setOffsetTop((origin) => {
@@ -574,7 +568,7 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
574568
offsetLeft,
575569
setInstanceRef,
576570
children,
577-
sharedConfig,
571+
getKey,
578572
);
579573

580574
let componentStyle: React.CSSProperties = null;

src/hooks/useChildren.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import type { RenderFunc, SharedConfig } from '../interface';
2+
import type { RenderFunc, GetKey } from '../interface';
33
import { Item } from '../Item';
44

55
export default function useChildren<T>(
@@ -10,7 +10,7 @@ export default function useChildren<T>(
1010
offsetX: number,
1111
setNodeRef: (item: T, element: HTMLElement) => void,
1212
renderFunc: RenderFunc<T>,
13-
{ getKey }: SharedConfig<T>,
13+
getKey: GetKey<T>,
1414
) {
1515
// 可能存在 list 不变但是里面的数据存在变化的情况,会与之前写法存在不同的行为
1616
return React.useMemo(() => {

src/interface.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ export type RenderFunc<T> = (
44
props: { style: React.CSSProperties; offsetX: number },
55
) => React.ReactNode;
66

7-
export interface SharedConfig<T> {
8-
getKey: (item: T) => React.Key;
9-
}
10-
117
export type GetKey<T> = (item: T) => React.Key;
128

139
export type GetSize = (startKey: React.Key, endKey?: React.Key) => { top: number; bottom: number };

0 commit comments

Comments
 (0)