react-infinite-scroll-component icon indicating copy to clipboard operation
react-infinite-scroll-component copied to clipboard

`scrollableTarget` throws error `Type 'HTMLElement' is not assignable to type 'ReactNode'` in React 18

Open na2793 opened this issue 3 years ago • 5 comments

https://codesandbox.io/s/young-frost-ujmz14?file=/src/index.tsx

I recently upgraded my project to React 18, then the following error started to occur :

image

With React 17, there was no problem at all.

I think HTMLElement has changed to no longer be part of ReactNode.

I knew it was possible to pass id value in form of a string to scrollableTarget, but I couldn't because the node I was trying to pass it to didn't have id.

What's the best way to handle this?

na2793 avatar Apr 05 '23 09:04 na2793

image

The type of scrollableTarget does not have to be ReactNode, it needs to be HTMLElement.

The value of scrollableTarget is usually a DOM element obtained using useRef(), but useRef() cannot provide a ReactNode other than HTMLElement.

na2793 avatar Apr 06 '23 10:04 na2793

This library seems to have been abandoned unfortunately. :(

bauerbach avatar Apr 21 '23 14:04 bauerbach

I upgraded from react 17 to react 18 and following issue started

'InfiniteScroll' cannot be used as a JSX component.
  Its instance type 'InfiniteScroll' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.
      Type 'Element' is not assignable to type 'ReactNode'.

ashwary23 avatar Jan 23 '24 10:01 ashwary23