Skip to content

Commit

Permalink
Cannot read property removeEventListener of null (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
gugods committed Mar 22, 2022
1 parent 8eb51c0 commit ed87012
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,11 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
componentRef.current.addEventListener('MozMousePixelScroll', onMozMousePixelScroll);

return () => {
componentRef.current.removeEventListener('wheel', onRawWheel);
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll as any);
componentRef.current.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll as any);
if(componentRef.current) {
componentRef.current.removeEventListener('wheel', onRawWheel);
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll as any);
componentRef.current.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll as any);
}
};
}, [useVirtual]);

Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useMobileTouchMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default function useMobileTouchMove(
}

return () => {
listRef.current.removeEventListener('touchstart', onTouchStart);
if(listRef.current) {
listRef.current.removeEventListener('touchstart', onTouchStart);
}
cleanUpEvents();
clearInterval(intervalRef.current);
};
Expand Down

1 comment on commit ed87012

@vercel
Copy link

@vercel vercel bot commented on ed87012 Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.