Skip to content

Commit ed87012

Browse files
authored
Cannot read property removeEventListener of null (#163)
1 parent 8eb51c0 commit ed87012

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/List.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,11 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
277277
componentRef.current.addEventListener('MozMousePixelScroll', onMozMousePixelScroll);
278278

279279
return () => {
280-
componentRef.current.removeEventListener('wheel', onRawWheel);
281-
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll as any);
282-
componentRef.current.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll as any);
280+
if(componentRef.current) {
281+
componentRef.current.removeEventListener('wheel', onRawWheel);
282+
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll as any);
283+
componentRef.current.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll as any);
284+
}
283285
};
284286
}, [useVirtual]);
285287

src/hooks/useMobileTouchMove.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export default function useMobileTouchMove(
7474
}
7575

7676
return () => {
77-
listRef.current.removeEventListener('touchstart', onTouchStart);
77+
if(listRef.current) {
78+
listRef.current.removeEventListener('touchstart', onTouchStart);
79+
}
7880
cleanUpEvents();
7981
clearInterval(intervalRef.current);
8082
};

0 commit comments

Comments
 (0)