fivecar / react-native-draglist

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

Revert "fix: remove typescript bypass on forwardRef (#31)" #37

Closed fivecar closed 8 months ago

fivecar commented 8 months ago

This reverts #31, which began to cause warnings and issues in React Native (because function components can't take a ref).

We then update how we handle the refs in Typescript so that there are no Typescript errors when you use the component. Verified working via example app.

fivecar commented 8 months ago

@trajano : just FYI, in case I've done something incorrectly. But this change gets rid of the React warnings, and also maintains Typescript correctness.

trajano commented 8 months ago

@trajano : just FYI, in case I've done something incorrectly. But this change gets rid of the React warnings, and also maintains Typescript correctness.

I'll have to check when I have time, but I use function components almost exclusively and forwardRef is a bit weird to use and I usually forget how to do it whenever I switch languages so I wrote up this example for myself.

https://github.com/trajano/react-hooks/blob/master/cookbook/hoc/withHoc.tsx