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

153
Visualizações
React JS Filter a 2D array for empty cells

Can you help me translate my method to an arrow function? Learning that atm, but this is a bit to complex for me already.

The state:

const [data, setData] = useState([]);

The array look something like that:

[
  [
    value: "---",
    value: "ColumnHeader1",
    value: "ColumnHeader2",
    value: "ColumnHeader3"
  ],
  [
    value: "RowHeader1",
    value: "Value11",
    value: "Value12",
    value: "Value13"
  ],
  [
    value: "RowHeader2",
    value: "Value21",
    value: "Value22",
    value: "Value23"
  ],
]

My method which is already working:

  function removeEmptyCells() {
    setData(prevState => {

        let array = [];

        for (let i = 0; i < prevState.length; i++) {
            console.log(prevState[i])

            let innerArray = []

            for (let x = 0; x < prevState[i].length; x++) {
                if (Object.keys(prevState[i][x]).length !== 0) {
                    innerArray.push(prevState[i][x])
                }
            }
            if (innerArray.length > 0) {
                array.push(innerArray);
            }

        }

        return array;
    })
}

Can you help me to translate this method to an arrow function?

about 4 years ago · Juan Pablo Isaza
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