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

Creation of a glossary , if else not working? (React Native) [duplicate]

$
0
0

I have an issue. I want to show a different color of letters if there is no data, but there seems to be an issue with my 'if' and all the data is show with the else. Here is my code:

  {letter.map((letter) => {            if (letter.data == []) {              return (<View><Text style={{ color: "#424242" }}>{letter.name}</Text></View>              );            } else {              return (<View><Text>{letter.name}</Text></View>              );            }          })}

And my data:

const letter = [  {    id: "1",    name: "A",    data: ["Abricot", "Abricot", "Abricot"],  },  {    id: "2",    name: "B",    data: ["Branche", "Branche", "Branche"],  },  {    id: "3",    name: "C",    data: [],  },  {    id: "4",    name: "D",    data: ["Dalle", "Dalle", "Dalle"],  },  {    id: "5",    name: "E",    data: [],  },];

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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