File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,11 @@ export const VirtualList = forwardRef(function <ITEM>(
127
127
}
128
128
129
129
useLayoutEffect ( ( ) => {
130
- setListSize ( list . current ! . clientHeight )
130
+ // list may be null in test environment
131
+ if ( ! list . current ) {
132
+ return
133
+ }
134
+ setListSize ( list . current . clientHeight )
131
135
// get avg item size
132
136
if ( props . itemSize == null ) {
133
137
// get gap
@@ -215,7 +219,8 @@ export const VirtualList = forwardRef(function <ITEM>(
215
219
const observer = ResizeObserver && new ResizeObserver ( ( ) => {
216
220
setListSize ( list . current ! . clientHeight )
217
221
} )
218
- observer . observe ( list . current as HTMLElement )
222
+ // observer is undefined in test environment
223
+ observer ?. observe ( list . current as HTMLElement )
219
224
return ( ) => {
220
225
observer ?. disconnect ( )
221
226
}
You can’t perform that action at this time.
0 commit comments