gluestack / gluestack-ui

React & React Native Components & Patterns (copy-paste components & patterns crafted with Tailwind CSS (NativeWind))
https://gluestack.io/
MIT License
2.45k stars 116 forks source link

FlatList lost types #1041

Open RobertSasak opened 1 year ago

RobertSasak commented 1 year ago

Description

FlatList renderItem is missing types

CodeSandbox/Snack link

https://snack.expo.dev/@robert.sasak/gluestack-flatlist-lost-types

Steps to reproduce

  1. Go to https://snack.expo.dev/@robert.sasak/gluestack-flatlist-lost-types
  2. Hover mouse over item in GSFlatList
  3. See error
    Binding element 'item' implicitly has an 'any' type.

For a comparison there is also a pure FlatList implementation that have correct types.

gluestack-ui Version

0.1.33

Platform

Other Platform

No response

Additional Information

Here is an actual error in Snack flatlist

There is also an addional error which I do not experience in my project. I do not think that this is related.

'GSFlatList' cannot be used as a JSX component.
  Its return type 'ReactNode' is not a valid JSX element.
    Type 'undefined' is not assignable to type 'Element | null'.
GollyJer commented 1 year ago

Came to mention the same thing. If I switch to the react-native FlatList all the errors go away.

ankit-tailor commented 1 year ago

Hi @GollyJer @RobertSasak, Thanks for reporting the issue. We will look into it.

coycoylaniba commented 11 months ago

the keyExtractor prop also does not infer the data prop type. image

marcorm commented 11 months ago

Same problem here. Versions:

"@gluestack-style/react": "^1.0.8",
"@gluestack-ui/config": "^1.0.3",
"@gluestack-ui/themed": "^1.0.8",

I had to do this (maybe it can help someone):

<FlatList
  data={playersData?.playersByClub}
  showsVerticalScrollIndicator={false}
  renderItem={({ item, index }) => (
    <PlayerListItem
      player={item as PlayerItemFragment}
      index={index}
      setSelectedPlayer={setSelectedPlayer}
    />
  )}
  keyExtractor={(item) => (item as PlayerItemFragment)._id}
/>

With react-native FlatList, no problems... Note that also SectionList has the same problem, and i couldn't find a workaround there (can someone help?).

Thanks a lot, love this library.

yaroslavignatenko commented 9 months ago

Are there any updates? this is still an issue for me Screenshot 2023-12-13 at 15 38 53

vinjegaard commented 4 months ago

This is still an issue in @gluestack-ui/themed": "^1.1.25", any updates on this?

Thanks!

TArch64 commented 4 months ago

It's the same issue as styled components has. Since all gluestack components wrapped in styled function it breaks any generic a component has

Simoon-F commented 4 months ago

+1

goodjun commented 4 months ago

+1

MasterSigmar commented 3 months ago

+1

Simoon-F commented 3 months ago

Textarea also have the same problem.

Simoon-F commented 3 months ago

Changing the version of @gluestack-ui/themed from ^1.1.29 to 1.1.29 can temporarily solve this problem.

    "@gluestack-style/react": "^1.0.56",
    "@gluestack-ui/config": "^1.1.18",
    "@gluestack-ui/themed": "1.1.29",