gluestack-ui icon indicating copy to clipboard operation
gluestack-ui copied to clipboard

FlatList lost types

Open RobertSasak opened this issue 2 years ago • 13 comments

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

  • [X] Expo
  • [ ] React Native CLI
  • [ ] Next
  • [X] Web
  • [ ] Android
  • [ ] iOS

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'.

RobertSasak avatar Sep 11 '23 06:09 RobertSasak

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

GollyJer avatar Sep 12 '23 22:09 GollyJer

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

ankit-tailor avatar Sep 14 '23 10:09 ankit-tailor

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

coycoylaniba avatar Nov 02 '23 20:11 coycoylaniba

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.

marcorm avatar Nov 04 '23 18:11 marcorm

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

yaroslavignatenko avatar Dec 13 '23 13:12 yaroslavignatenko

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

Thanks!

vinjegaard avatar May 08 '24 17:05 vinjegaard

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

TArch64 avatar May 19 '24 11:05 TArch64

+1

Simoon-F avatar May 29 '24 06:05 Simoon-F

+1

goodjun avatar Jun 01 '24 02:06 goodjun

+1

MasterSigmar avatar Jun 13 '24 17:06 MasterSigmar

Textarea also have the same problem.

Simoon-F avatar Jun 25 '24 23:06 Simoon-F

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",

Simoon-F avatar Jun 26 '24 00:06 Simoon-F