fivecar / react-native-draglist

FlatList that can be reordered by dragging its items
MIT License
119 stars 19 forks source link

`Warning: forwardRef render functions` #28

Closed osmanyz closed 12 months ago

osmanyz commented 12 months ago

Hello,

I have to use some good package for the project. I found out that your library is pretty good, it helped me a lot.

But I'm getting an error after started using it.

Current Behavior

It throws an error about forwardRef. error

This is the exact code. As you see it has no change at all.

<DragList
      data={data}
      keyExtractor={keyExtractor}
      onReordered={onReordered}
      renderItem={renderItem}
      />

Expected Behavior

It shouldn't throw an error regarding the forwardRef functionality.

Platform (Web, iOS, Android)

ios, android.

System Info

  System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 2.30 GB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.3.0 - ~/.nvm/versions/node/v18.3.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.4 - ~/Workhub/cercose/testapp/node_modules/.bin/npm
    pnpm: 8.7.6 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 118.0.5993.117
    Safari: 16.3
osmanyz commented 12 months ago

This is the solution which i found it.

https://github.com/fivecar/react-native-draglist/blob/7a7ddb27303df6f799dbff8fa86433cb2ca72ea9/src/index.tsx#L434

export const DragList: WithForwardRefType = React.forwardRef(DragListImpl);

I've changed as this.

export const DragList: WithForwardRefType = React.forwardRef((props, ref) => (
  <DragListImpl ref={ref} {...props}>
    {props.children}
  </DragListImpl>
));

And then the error is gone.