Home > Mobile >  Unable to map the array and get the values on Screen React Native
Unable to map the array and get the values on Screen React Native

Time:12-05

const DynPut: FC<Props> = Props => {

const [value, setValue] = useState<string>(['1', '2', '3', '4']);

  return (
    <View>
      {value.map(v => {
        <Text>{v}</Text>;
      })}
    </View>
  );
};

Unable to get the values 1-5 on the screen. am using typescript and also saved the file with .tsx extension

CodePudding user response:

The syntax for the map is wrong, use normal brackets instead:

{value.map((v) => (
    <Text>{v}</Text>
))}
  • Related