You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cleanup function of the useEffect in useResizeObserver can in some cases call unobserve with an empty ref, which will throw a TypeError (Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element'.).
At least, this is what I think happens. If I add a check for ref.current existing, it works fine.
This seems like it happens when for example rendering a ScrollView inside a modal/popover that unmounts before the cleanup effect is called, in my case I was trying to use a Virtualizer inside a Popover (see code example). For some reason that I can't figure out, this doesn't happen for the react-spectrum Picker component, although it uses a Virtualizer in this same sense.
@karlpetersson Thanks for reporting this, I think your solution is reasonable. My guess would be that it works for Picker due to the transition the overlay wrapping the popover has.
馃悰 Bug Report
The cleanup function of the
useEffect
inuseResizeObserver
can in some cases callunobserve
with an empty ref, which will throw a TypeError (Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element'.).react-spectrum/packages/@react-aria/utils/src/useResizeObserver.ts
Lines 36 to 38 in 6e9f55a
At least, this is what I think happens. If I add a check for
ref.current
existing, it works fine.This seems like it happens when for example rendering a ScrollView inside a modal/popover that unmounts before the cleanup effect is called, in my case I was trying to use a
Virtualizer
inside a Popover (see code example). For some reason that I can't figure out, this doesn't happen for the react-spectrum Picker component, although it uses a Virtualizer in this same sense.Here's a codesandbox where this issue is present. Opening then closing the Select throws the mentioned error. https://codesandbox.io/s/affectionate-vaughan-bcy0f?file=/src/App.tsx
馃 Expected Behavior
馃槸 Current Behavior
馃拋 Possible Solution
I think changing the cleanup function in the
useEffect
inuseResizeObserver
to something like this could suffice:馃敠 Context
I am building a custom Select component using the react-aria hooks as well as the Virtualizer component.
馃捇 Code Sample
https://codesandbox.io/s/affectionate-vaughan-bcy0f?file=/src/App.tsx
馃實 Your Environment
馃Б Your Company/Team
Visly
馃暦 Tracking Issue (optional)
The text was updated successfully, but these errors were encountered: