Closed habovh closed 1 year ago
@habovh which version are you using?
Can you share a code snippet or screenshot of what you are seeing?
You can see it in action here. Version is 1.5.3.
Hovering the first parameter gives an implicit any type error:
And looking at flatListProps.d.ts
, you can see there's no generics that could carry types between list
and renderItem
:
For comparison, here is the same component using React Native's flatlist.
Item type is inferred properly:
And here's what the exported types look like (I moved code around to make this screenshot smaller):
Thanks. Its being worked on
fix available on next npm i flatlist-react@next
https://www.npmjs.com/package/flatlist-react/v/1.5.5-next
Is your feature request related to a problem? Please describe. The first parameter of the
renderItem
function is being typed asany
and is therefore not type-safe.Describe the solution you'd like Ideally,
<FlatList />
should infer the type from thelist
prop. React Native's<FlatList />
component supports this.Describe alternatives you've considered The current workaround is to manually set the type when defining the function. It's less than ideal because it's a manual step and it's not helping keep the code lean.