petyosi / react-virtuoso

The most powerful virtual list component for React
https://virtuoso.dev
MIT License
5.25k stars 301 forks source link

Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element'. #527

Closed andrewdeanyoder closed 2 years ago

andrewdeanyoder commented 2 years ago

Describe the bug Hello, thanks for this great library. I'm attempting to open an issue for another bug I ran into with Jest & React-Testing-Library, but I'm not able to finish the reproduction because of an error in CodeSandBox. After several months of working with react-virtuoso in prod code, I've never run into this error before.

Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element'.

I attempted the solution here, but that hasn't worked.

I also saw this issue, but wasn't sure how that could be handled in my current repo. Any help would be appreciated.

Reproduction https://codesandbox.io/s/vigorous-roentgen-ie44f?file=/src/__tests___/SimpleList.js

To Reproduce Steps to reproduce the behavior:

  1. Go to the code sandbox.
  2. Attempt to run the test suite
petyosi commented 2 years ago

I can't say for sure what's the problem, as I am not using react-testing-library - most likely the element passed to the observer is some stub. You can probably mock the entire ResizeObserver API to avoid that, but this is likely to result in the component not working.

You can check the tests and e2e of the library for further reference.