Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda