bvaughn / react-virtualized

React components for efficiently rendering large lists and tabular data
http://bvaughn.github.io/react-virtualized/
MIT License
26.1k stars 3.05k forks source link

TypeError : RegisterChild in WindowScroller #1829

Open chelsadaptry98 opened 5 months ago

chelsadaptry98 commented 5 months ago

Bug Report

I am using react-virtualized in React 18 with typescript. RegisterChild in windowScroller gives a typeError when used as a ref.

What is the current behavior?

When I use

I get an an error as :

Type '(element?: ReactNode) => void' is not assignable to type 'LegacyRef<HTMLDivElement> | undefined'.
  Type '(element?: ReactNode) => void' is not assignable to type '(instance: HTMLDivElement | null) => void'.
    Types of parameters 'element' and 'instance' are incompatible.
      Type 'HTMLDivElement | null' is not assignable to type 'ReactNode'.
        Type 'HTMLDivElement' is not assignable to type 'ReactNode'.
          Type 'HTMLDivElement' is missing the following properties from type 'ReactPortal': type, props, key

Screenshot 2024-01-08 at 10 49 52 PM

How can I solve this error?

If I use onChildScroll, I get a warning in console for ReactDomNode

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of WindowScroller which is inside StrictMode. Instead, add a ref directly to the element you want to reference

What is the expected behavior?

registerChild should work as ref correctly.

Which versions of React and react-virtualized, and which browser / OS are affected by this issue? Did this work in previous versions of react-virtualized?

I am trying to update to react 18 from react 17 and encountered this issue
Browser Chrome
OS Mac
React 18.0.2
React DOM 18.0.2
react-virtualized 9.22.5