@react-aria/virtualizer 4.0.3 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/ScrollView.main.js +4 -8
- package/dist/ScrollView.main.js.map +1 -1
- package/dist/ScrollView.mjs +4 -8
- package/dist/ScrollView.module.js +4 -8
- package/dist/ScrollView.module.js.map +1 -1
- package/dist/Virtualizer.main.js +7 -8
- package/dist/Virtualizer.main.js.map +1 -1
- package/dist/Virtualizer.mjs +9 -10
- package/dist/Virtualizer.module.js +9 -10
- package/dist/Virtualizer.module.js.map +1 -1
- package/dist/VirtualizerItem.main.js +3 -2
- package/dist/VirtualizerItem.main.js.map +1 -1
- package/dist/VirtualizerItem.mjs +3 -2
- package/dist/VirtualizerItem.module.js +3 -2
- package/dist/VirtualizerItem.module.js.map +1 -1
- package/dist/types.d.ts +172 -171
- package/dist/types.d.ts.map +1 -1
- package/dist/useVirtualizerItem.main.js +4 -3
- package/dist/useVirtualizerItem.main.js.map +1 -1
- package/dist/useVirtualizerItem.mjs +4 -3
- package/dist/useVirtualizerItem.module.js +4 -3
- package/dist/useVirtualizerItem.module.js.map +1 -1
- package/package.json +11 -10
- package/src/ScrollView.tsx +12 -6
- package/src/Virtualizer.tsx +10 -11
- package/src/VirtualizerItem.tsx +4 -3
- package/src/useVirtualizerItem.ts +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IACrC,IAAI,MAAM,uBAAA,iCAAA,WAAY,GAAG;IAEzB,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE;QAC3B,IAAI,OAAO,QAAQ,IAAI,OAAO,EAAE;YAC9B,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,KAAK;QAClC;IACF,GAAG;QAAC;QAAa;QAAK;KAAI;IAE1B,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,uBAAA,iCAAA,WAAY,aAAa,EAC3B;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/useVirtualizerItem.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key, RefObject} from '@react-types/shared';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {useCallback} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\ninterface IVirtualizer {\n updateItemSize(key: Key, size: Size): void\n}\n\nexport interface VirtualizerItemOptions {\n layoutInfo: LayoutInfo | null,\n virtualizer: IVirtualizer,\n ref: RefObject<HTMLElement | null>\n}\n\nexport function useVirtualizerItem(options: VirtualizerItemOptions) {\n let {layoutInfo, virtualizer, ref} = options;\n let key = layoutInfo?.key;\n\n let updateSize = useCallback(() => {\n if (key != null && ref.current) {\n let size = getSize(ref.current);\n virtualizer.updateItemSize(key, size);\n }\n }, [virtualizer, key, ref]);\n\n useLayoutEffect(() => {\n if (layoutInfo?.estimatedSize) {\n updateSize();\n }\n });\n\n return {updateSize};\n}\n\nfunction getSize(node: HTMLElement) {\n // Reset height before measuring so we get the intrinsic size\n let height = node.style.height;\n node.style.height = '';\n let size = new Size(node.scrollWidth, node.scrollHeight);\n node.style.height = height;\n return size;\n}\n"],"names":[],"version":3,"file":"useVirtualizerItem.main.js.map"}
|
|
@@ -17,14 +17,15 @@ import {useLayoutEffect as $uBoVA$useLayoutEffect} from "@react-aria/utils";
|
|
|
17
17
|
|
|
18
18
|
function $47736c1e63ba1c6d$export$1da781778207e0a2(options) {
|
|
19
19
|
let { layoutInfo: layoutInfo, virtualizer: virtualizer, ref: ref } = options;
|
|
20
|
+
let key = layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.key;
|
|
20
21
|
let updateSize = (0, $uBoVA$useCallback)(()=>{
|
|
21
|
-
if (
|
|
22
|
+
if (key != null && ref.current) {
|
|
22
23
|
let size = $47736c1e63ba1c6d$var$getSize(ref.current);
|
|
23
|
-
virtualizer.updateItemSize(
|
|
24
|
+
virtualizer.updateItemSize(key, size);
|
|
24
25
|
}
|
|
25
26
|
}, [
|
|
26
27
|
virtualizer,
|
|
27
|
-
|
|
28
|
+
key,
|
|
28
29
|
ref
|
|
29
30
|
]);
|
|
30
31
|
(0, $uBoVA$useLayoutEffect)(()=>{
|
|
@@ -17,14 +17,15 @@ import {useLayoutEffect as $uBoVA$useLayoutEffect} from "@react-aria/utils";
|
|
|
17
17
|
|
|
18
18
|
function $47736c1e63ba1c6d$export$1da781778207e0a2(options) {
|
|
19
19
|
let { layoutInfo: layoutInfo, virtualizer: virtualizer, ref: ref } = options;
|
|
20
|
+
let key = layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.key;
|
|
20
21
|
let updateSize = (0, $uBoVA$useCallback)(()=>{
|
|
21
|
-
if (
|
|
22
|
+
if (key != null && ref.current) {
|
|
22
23
|
let size = $47736c1e63ba1c6d$var$getSize(ref.current);
|
|
23
|
-
virtualizer.updateItemSize(
|
|
24
|
+
virtualizer.updateItemSize(key, size);
|
|
24
25
|
}
|
|
25
26
|
}, [
|
|
26
27
|
virtualizer,
|
|
27
|
-
|
|
28
|
+
key,
|
|
28
29
|
ref
|
|
29
30
|
]);
|
|
30
31
|
(0, $uBoVA$useLayoutEffect)(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IACrC,IAAI,MAAM,uBAAA,iCAAA,WAAY,GAAG;IAEzB,IAAI,aAAa,CAAA,GAAA,kBAAU,EAAE;QAC3B,IAAI,OAAO,QAAQ,IAAI,OAAO,EAAE;YAC9B,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,KAAK;QAClC;IACF,GAAG;QAAC;QAAa;QAAK;KAAI;IAE1B,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,uBAAA,iCAAA,WAAY,aAAa,EAC3B;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,WAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/useVirtualizerItem.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key, RefObject} from '@react-types/shared';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {useCallback} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\ninterface IVirtualizer {\n updateItemSize(key: Key, size: Size): void\n}\n\nexport interface VirtualizerItemOptions {\n layoutInfo: LayoutInfo | null,\n virtualizer: IVirtualizer,\n ref: RefObject<HTMLElement | null>\n}\n\nexport function useVirtualizerItem(options: VirtualizerItemOptions) {\n let {layoutInfo, virtualizer, ref} = options;\n let key = layoutInfo?.key;\n\n let updateSize = useCallback(() => {\n if (key != null && ref.current) {\n let size = getSize(ref.current);\n virtualizer.updateItemSize(key, size);\n }\n }, [virtualizer, key, ref]);\n\n useLayoutEffect(() => {\n if (layoutInfo?.estimatedSize) {\n updateSize();\n }\n });\n\n return {updateSize};\n}\n\nfunction getSize(node: HTMLElement) {\n // Reset height before measuring so we get the intrinsic size\n let height = node.style.height;\n node.style.height = '';\n let size = new Size(node.scrollWidth, node.scrollHeight);\n node.style.height = height;\n return size;\n}\n"],"names":[],"version":3,"file":"useVirtualizerItem.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/virtualizer",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,18 +22,19 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/i18n": "^3.12.
|
|
26
|
-
"@react-aria/interactions": "^3.22.
|
|
27
|
-
"@react-aria/utils": "^3.
|
|
28
|
-
"@react-stately/virtualizer": "^4.
|
|
29
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-aria/i18n": "^3.12.4",
|
|
26
|
+
"@react-aria/interactions": "^3.22.5",
|
|
27
|
+
"@react-aria/utils": "^3.26.0",
|
|
28
|
+
"@react-stately/virtualizer": "^4.2.0",
|
|
29
|
+
"@react-types/shared": "^3.26.0",
|
|
30
30
|
"@swc/helpers": "^0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
34
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
33
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
34
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
|
-
}
|
|
39
|
-
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
|
|
40
|
+
}
|
package/src/ScrollView.tsx
CHANGED
|
@@ -44,7 +44,7 @@ function ScrollView(props: ScrollViewProps, ref: ForwardedRef<HTMLDivElement | n
|
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
46
|
<div role="presentation" {...scrollViewProps} ref={ref}>
|
|
47
|
-
<div
|
|
47
|
+
<div {...contentProps}>
|
|
48
48
|
{props.children}
|
|
49
49
|
</div>
|
|
50
50
|
</div>
|
|
@@ -69,7 +69,7 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
|
|
|
69
69
|
scrollTop: 0,
|
|
70
70
|
scrollLeft: 0,
|
|
71
71
|
scrollEndTime: 0,
|
|
72
|
-
scrollTimeout: null,
|
|
72
|
+
scrollTimeout: null as ReturnType<typeof setTimeout> | null,
|
|
73
73
|
width: 0,
|
|
74
74
|
height: 0,
|
|
75
75
|
isScrolling: false
|
|
@@ -114,7 +114,10 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
|
|
|
114
114
|
if (state.scrollEndTime <= now + 50) {
|
|
115
115
|
state.scrollEndTime = now + 300;
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
if (state.scrollTimeout != null) {
|
|
118
|
+
clearTimeout(state.scrollTimeout);
|
|
119
|
+
}
|
|
120
|
+
|
|
118
121
|
state.scrollTimeout = setTimeout(() => {
|
|
119
122
|
state.isScrolling = false;
|
|
120
123
|
setScrolling(false);
|
|
@@ -132,10 +135,13 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
|
|
|
132
135
|
// Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.
|
|
133
136
|
useEvent(ref, 'scroll', onScroll);
|
|
134
137
|
|
|
135
|
-
|
|
138
|
+
|
|
136
139
|
useEffect(() => {
|
|
137
140
|
return () => {
|
|
138
|
-
|
|
141
|
+
if (state.scrollTimeout != null) {
|
|
142
|
+
clearTimeout(state.scrollTimeout);
|
|
143
|
+
}
|
|
144
|
+
|
|
139
145
|
if (state.isScrolling) {
|
|
140
146
|
window.dispatchEvent(new Event('tk.connect-observer'));
|
|
141
147
|
}
|
|
@@ -146,7 +152,7 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
|
|
|
146
152
|
let isUpdatingSize = useRef(false);
|
|
147
153
|
let updateSize = useEffectEvent((flush: typeof flushSync) => {
|
|
148
154
|
let dom = ref.current;
|
|
149
|
-
if (!dom
|
|
155
|
+
if (!dom || isUpdatingSize.current) {
|
|
150
156
|
return;
|
|
151
157
|
}
|
|
152
158
|
|
package/src/Virtualizer.tsx
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import {Collection, Key, RefObject} from '@react-types/shared';
|
|
14
14
|
import {Layout, Rect, ReusableView, useVirtualizerState} from '@react-stately/virtualizer';
|
|
15
|
-
import {mergeProps, useLoadMore} from '@react-aria/utils';
|
|
16
|
-
import React, {HTMLAttributes, ReactElement, ReactNode, useCallback
|
|
15
|
+
import {mergeProps, useLoadMore, useObjectRef} from '@react-aria/utils';
|
|
16
|
+
import React, {ForwardedRef, HTMLAttributes, ReactElement, ReactNode, useCallback} from 'react';
|
|
17
17
|
import {ScrollView} from './ScrollView';
|
|
18
18
|
import {VirtualizerItem} from './VirtualizerItem';
|
|
19
19
|
|
|
@@ -22,7 +22,7 @@ type RenderWrapper<T extends object, V> = (
|
|
|
22
22
|
reusableView: ReusableView<T, V>,
|
|
23
23
|
children: ReusableView<T, V>[],
|
|
24
24
|
renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]
|
|
25
|
-
) => ReactElement;
|
|
25
|
+
) => ReactElement | null;
|
|
26
26
|
|
|
27
27
|
interface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
28
28
|
children: (type: string, content: T) => V,
|
|
@@ -36,32 +36,31 @@ interface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<H
|
|
|
36
36
|
layoutOptions?: O
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
function Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>,
|
|
39
|
+
function Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>, forwardedRef: ForwardedRef<HTMLDivElement | null>) {
|
|
40
40
|
let {
|
|
41
41
|
children: renderView,
|
|
42
42
|
renderWrapper,
|
|
43
43
|
layout,
|
|
44
44
|
collection,
|
|
45
45
|
scrollDirection,
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
47
46
|
isLoading,
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
49
47
|
onLoadMore,
|
|
50
48
|
persistedKeys,
|
|
51
49
|
layoutOptions,
|
|
52
50
|
...otherProps
|
|
53
51
|
} = props;
|
|
54
52
|
|
|
55
|
-
let
|
|
56
|
-
ref = ref || fallbackRef;
|
|
53
|
+
let ref = useObjectRef(forwardedRef);
|
|
57
54
|
|
|
58
55
|
let state = useVirtualizerState({
|
|
59
56
|
layout,
|
|
60
57
|
collection,
|
|
61
58
|
renderView,
|
|
62
59
|
onVisibleRectChange(rect) {
|
|
63
|
-
ref.current
|
|
64
|
-
|
|
60
|
+
if (ref.current) {
|
|
61
|
+
ref.current.scrollLeft = rect.x;
|
|
62
|
+
ref.current.scrollTop = rect.y;
|
|
63
|
+
}
|
|
65
64
|
},
|
|
66
65
|
persistedKeys,
|
|
67
66
|
layoutOptions
|
|
@@ -108,7 +107,7 @@ function defaultRenderWrapper<T extends object, V extends ReactNode>(
|
|
|
108
107
|
return (
|
|
109
108
|
<VirtualizerItem
|
|
110
109
|
key={reusableView.key}
|
|
111
|
-
layoutInfo={reusableView.layoutInfo}
|
|
110
|
+
layoutInfo={reusableView.layoutInfo!}
|
|
112
111
|
virtualizer={reusableView.virtualizer}
|
|
113
112
|
parent={parent?.layoutInfo}>
|
|
114
113
|
{reusableView.rendered}
|
package/src/VirtualizerItem.tsx
CHANGED
|
@@ -17,6 +17,7 @@ import {useLocale} from '@react-aria/i18n';
|
|
|
17
17
|
import {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';
|
|
18
18
|
|
|
19
19
|
interface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {
|
|
20
|
+
layoutInfo: LayoutInfo,
|
|
20
21
|
parent?: LayoutInfo | null,
|
|
21
22
|
style?: CSSProperties,
|
|
22
23
|
className?: string,
|
|
@@ -26,7 +27,7 @@ interface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {
|
|
|
26
27
|
export function VirtualizerItem(props: VirtualizerItemProps) {
|
|
27
28
|
let {style, className, layoutInfo, virtualizer, parent, children} = props;
|
|
28
29
|
let {direction} = useLocale();
|
|
29
|
-
let ref = useRef(
|
|
30
|
+
let ref = useRef<HTMLDivElement | null>(null);
|
|
30
31
|
useVirtualizerItem({
|
|
31
32
|
layoutInfo,
|
|
32
33
|
virtualizer,
|
|
@@ -57,7 +58,7 @@ export function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
let rectStyles = {
|
|
61
|
+
let rectStyles: Record<string, number | undefined> = {
|
|
61
62
|
// TODO: For layoutInfos that are sticky that have parents with overflow visible, their "top" will be relative to the to the nearest scrolling container
|
|
62
63
|
// which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position
|
|
63
64
|
// Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the
|
|
@@ -82,7 +83,7 @@ export function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent
|
|
|
82
83
|
overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
|
|
83
84
|
opacity: layoutInfo.opacity,
|
|
84
85
|
zIndex: layoutInfo.zIndex,
|
|
85
|
-
transform: layoutInfo.transform,
|
|
86
|
+
transform: layoutInfo.transform ?? undefined,
|
|
86
87
|
contain: 'size layout style',
|
|
87
88
|
...rectStyles
|
|
88
89
|
};
|
|
@@ -20,20 +20,21 @@ interface IVirtualizer {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface VirtualizerItemOptions {
|
|
23
|
-
layoutInfo: LayoutInfo,
|
|
23
|
+
layoutInfo: LayoutInfo | null,
|
|
24
24
|
virtualizer: IVirtualizer,
|
|
25
25
|
ref: RefObject<HTMLElement | null>
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function useVirtualizerItem(options: VirtualizerItemOptions) {
|
|
29
29
|
let {layoutInfo, virtualizer, ref} = options;
|
|
30
|
+
let key = layoutInfo?.key;
|
|
30
31
|
|
|
31
32
|
let updateSize = useCallback(() => {
|
|
32
|
-
if (
|
|
33
|
+
if (key != null && ref.current) {
|
|
33
34
|
let size = getSize(ref.current);
|
|
34
|
-
virtualizer.updateItemSize(
|
|
35
|
+
virtualizer.updateItemSize(key, size);
|
|
35
36
|
}
|
|
36
|
-
}, [virtualizer,
|
|
37
|
+
}, [virtualizer, key, ref]);
|
|
37
38
|
|
|
38
39
|
useLayoutEffect(() => {
|
|
39
40
|
if (layoutInfo?.estimatedSize) {
|