Cannot read property 'removeEventListener' of null
This line of useMobileTouchMove.ts requires a null check on listRef.current:
listRef.current.removeEventListener('touchstart', onTouchStart);
When a Select component in the latest ant design v4.6.5 is unmounted (ie. removed from the DOM), we get the following exception:
scheduler.development.js?034b:171 Uncaught TypeError: Cannot read property 'removeEventListener' of null
at eval (useMobileTouchMove.js?684c:64)
at HTMLUnknownElement.callCallback (react-dom.development.js?4b4a:3946)
at Object.invokeGuardedCallbackDev (react-dom.development.js?4b4a:3995)
at invokeGuardedCallback (react-dom.development.js?4b4a:4057)
at safelyCallDestroy (react-dom.development.js?4b4a:20501)
at commitHookEffectListUnmount2 (react-dom.development.js?4b4a:20634)
at commitPassiveUnmount (react-dom.development.js?4b4a:21705)
at flushPassiveUnmountEffectsInsideOfDeletedTree (react-dom.development.js?4b4a:23600)
at flushPassiveUnmountEffectsInsideOfDeletedTree (react-dom.development.js?4b4a:23593)
at flushPassiveUnmountEffectsInsideOfDeletedTree (react-dom.development
Same error coming also from List.ts when a Select component is unmounted
return function () {
componentRef.current.removeEventListener('wheel', onRawWheel);
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll);
componentRef.current.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll);
};
List.js?2762:259 Uncaught TypeError: Cannot read property 'removeEventListener' of null
at eval (List.js?2762:259)
at HTMLUnknownElement.callCallback (react-dom.development.js?4b4a:3946)
at Object.invokeGuardedCallbackDev (react-dom.development.js?4b4a:3995)
at invokeGuardedCallback (react-dom.development.js?4b4a:4057)
at safelyCallDestroy (react-dom.development.js?4b4a:20501)
at commitHookEffectListUnmount2 (react-dom.development.js?4b4a:20634)
at commitPassiveUnmount (react-dom.development.js?4b4a:21705)
at flushPassiveUnmountEffectsInsideOfDeletedTree (react-dom.development.js?4b4a:23600)
at flushPassiveUnmountEffectsInsideOfDeletedTree (react-dom.development.js?4b4a:23593)
at flushPassiveUnmountEffectsInsideOfDeletedTree (react-dom.development.js?4b4a:23593)
Same here ! For us it started happening after upgrading to React 17. See : https://reactjs.org/blog/2020/08/10/react-v17-rc.html#potential-issues
the problem still exists on CRA 4.0 and react 17
The issue seems to be fixed in https://github.com/react-component/virtual-list/pull/67
In my project rc-virtual-list was a dependency of rc-select. Just ran npm update to update to their latest versions and the problem went away. (This is tested with CRA 4.0 and react 17)
I have this problem on NextJs 10.2.3 and react 17 when click dropdown select