Skip to content

Commit 45fd1c4

Browse files
committed
chore: update virtual list ref typing
1 parent 597450f commit 45fd1c4

4 files changed

Lines changed: 12 additions & 26 deletions

File tree

src/Item.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import * as React from 'react';
22

33
export interface ItemProps {
44
children: React.ReactElement;
5-
setRef: (element: HTMLElement) => void;
5+
setRef: (element: HTMLElement | null) => void;
66
}
77

88
export function Item({ children, setRef }: ItemProps) {
99
const refFunc = React.useCallback(
10-
node => {
10+
(node) => {
1111
setRef(node);
1212
},
1313
[setRef],

src/hooks/useChildren.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function useChildren<T>(
88
endIndex: number,
99
scrollWidth: number,
1010
offsetX: number,
11-
setNodeRef: (item: T, element: HTMLElement) => void,
11+
setNodeRef: (item: T, element: HTMLElement | null) => void,
1212
renderFunc: RenderFunc<T>,
1313
{ getKey }: SharedConfig<T>,
1414
) {

src/hooks/useHeights.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function useHeights<T>(
1313
onItemAdd?: (item: T) => void,
1414
onItemRemove?: (item: T) => void,
1515
): [
16-
setInstanceRef: (item: T, instance: HTMLElement) => void,
16+
setInstanceRef: (item: T, instance: HTMLElement | null) => void,
1717
collectHeight: (sync?: boolean) => void,
1818
cacheMap: CacheMap,
1919
updatedMark: number,
@@ -69,7 +69,7 @@ export default function useHeights<T>(
6969
}
7070
}
7171

72-
function setInstanceRef(item: T, instance: HTMLElement) {
72+
function setInstanceRef(item: T, instance: HTMLElement | null) {
7373
const key = getKey(item);
7474
const origin = instanceRef.current.get(key);
7575

tsconfig.json

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,16 @@
22
"compilerOptions": {
33
"target": "esnext",
44
"moduleResolution": "bundler",
5-
"jsx": "react",
5+
"jsx": "react-jsx",
66
"declaration": true,
77
"skipLibCheck": true,
88
"esModuleInterop": true,
99
"paths": {
10-
"@/*": [
11-
"./src/*"
12-
],
13-
"@@/*": [
14-
"./.dumi/tmp/*"
15-
],
16-
"@rc-component/virtual-list": [
17-
"./src/index.ts"
18-
],
19-
"@rc-component/virtual-list/es": [
20-
"./src"
21-
],
22-
"@rc-component/virtual-list/es/*": [
23-
"./src/*"
24-
]
10+
"@/*": ["./src/*"],
11+
"@@/*": ["./.dumi/tmp/*"],
12+
"@rc-component/virtual-list": ["./src/index.ts"],
13+
"@rc-component/virtual-list/es": ["./src"],
14+
"@rc-component/virtual-list/es/*": ["./src/*"]
2515
},
2616
"noImplicitAny": false,
2717
"strictNullChecks": false,
@@ -41,9 +31,5 @@
4131
"tests",
4232
"examples"
4333
],
44-
"exclude": [
45-
"docs-dist",
46-
"lib",
47-
"es"
48-
]
34+
"exclude": ["docs-dist", "lib", "es"]
4935
}

0 commit comments

Comments
 (0)