Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React Native : Error in the data part of Flatlist

$
0
0

I tried using Flatlist in order to respond to one of my issue but I got an error on the data= of my Flatlist . I don't rreally undersstand the issue and the error message is not helping ( No overload matches this call. Overload 1 of 2, '(props: FlatListProps<any> | Readonly<FlatListProps<any>>): FlatList<any>', gave the following error. Type '{ id: string; name: string; data: string[]; description: string[]; }' is missing the following properties from type 'readonly any[]': length, concat, join, slice, and 19 more. )I used flatlist because of this : React Native : Conditional Views.Here is my code:

<View style={{ flex: 10}}>            {letter.map((letter) => {              const isleetergotdata = letter.data?.length > 0;              if (!isleetergotdata) {                return null;              }              return (<View                  style={{                    flex: 1,                    flexDirection: "row",                  }}><div                    ref={fieldRef}                    style={{                      marginBottom: 100,                    }}><Text                      style={{                        fontSize: 90,                      }}>                      {letter.name}</Text></div>                  {letter.data?.map((item, index) => {                    if (total !== same) {                      return (<FlatList                          data={letter} // HERE IS THE ISSUE                          numColumns={2}                          keyExtractor={(_, index) => index.toString()}                          renderItem={({ item }) => {                            return (<View><Text>{letter.description[index]}</Text></View>                            );                          }}                        />                      );                    }                   })}</View>              );            })}</View>

And here is my data:

const letter = [  {    id: "1",    name: "A",    data: ["Abricot", "Abricot", "Abricot"],    description: ["Un abricot est un fruit","Un abricot est un fruit","Un abricot est un fruit",    ],  },//...  {    id: "5",    name: "E",    data: [],    description: [],  },//...];

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>