Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

466
Visualizações
How Can I render Two-dimensions-Array in JSX (React Native)?

I am coding Two-dimensions-Array in ReactNative.

Single-Array is successful in JSX.
But I do not get how to use Two-dimensions-Array in JSX.
Can we use Two-dimensions-Array in JSX ?

Rendering is successful

<View>
  {myDoubleArray.map(loop => {
    return <Text>{loop}</Text>;
  })}
</View>

Rendering is nothing (my question)

<View>
  {myDoubleArray.map(loop => {
    loop.map(elm => {
      return <Text>{elm}</Text>;
    });
  })}
</View>

myDoubleArray is Two-dimensions-Array like this.

const myDoubleArray = new Array(5).fill(null);
for (let y = 0; y < 5; y++) {
  myDoubleArray[y] = new Array(3);
  for (let x = 0; x < 3; x++) {
    myDoubleArray[y][x] = y + ' : ' + x;
  }
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You do not return a value from the outer map function. So, the product of it is an array of undefineds. You just need a return statement:

<View>
  {myDoubleArray.map(loop => {
    return loop.map(elm => {
      return <Text>{elm}</Text>;
    });
  })}
</View>
about 4 years ago · Juan Pablo Isaza Relatório

0

There are two problems in your code you don't return anything and you forgot to assign a key I used the indexes it's not great but I don't know the contents of your array.

<View>
  {myDoubleArray.map((loop, indexA) => 
    loop.map((elm, indexB) => (
      <Text key={`${indexA}_${indexB}`}>{elm}</Text>
    ))
  )}
</View>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda