virtual-list icon indicating copy to clipboard operation
virtual-list copied to clipboard

Cannot read property 'removeEventListener' of null

Open nite opened this issue 5 years ago • 5 comments

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

nite avatar Oct 21 '20 17:10 nite

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)

ovidiufilos-temp avatar Oct 21 '20 17:10 ovidiufilos-temp

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

greggailly avatar Oct 23 '20 09:10 greggailly

the problem still exists on CRA 4.0 and react 17

beqramo avatar Nov 05 '20 12:11 beqramo

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)

bhumijgupta avatar Nov 18 '20 05:11 bhumijgupta

I have this problem on NextJs 10.2.3 and react 17 when click dropdown select

zandztormz avatar Nov 30 '21 07:11 zandztormz