cc @dvnrsn. This fixes a bug that I think was maybe caused by upgrading to React 17, where it says Cannot read property removeEventListener of undefined. I think the bug is caused by useEffect being cleaned up after dom operations are finished, which destroys the refs and dom elements stored in refs. By switching to useLayoutEffect, we clean up our event listeners before the ref and dom elements are destroyed.
cc @dvnrsn. This fixes a bug that I think was maybe caused by upgrading to React 17, where it says Cannot read property removeEventListener of undefined. I think the bug is caused by
useEffect
being cleaned up after dom operations are finished, which destroys the refs and dom elements stored in refs. By switching touseLayoutEffect
, we clean up our event listeners before the ref and dom elements are destroyed.