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

101
Vistas
Get to array in react state

I am using redux for state management on react-native and I am a total rookie, be warned ;)

I am converting my static data to using the product state instead of an array.

This is my static product array which will later be fetched from an API.

    const products = [
       {id: 1, title: 'Apple Pie'},
    ];

On app load I set the state like this:

    useEffect(() => {
      dispatch(allActions.productActions.setProducts(products))
    },[]);

On my view I call the getItem function, which works fine with the static array

    function getItem(itemId) {
      let obj = products.filter(item => item.id === itemId);
      return obj[0];
    }

the function returns an undefined object error, because it expects the actual array and not the state object.

The products state looks like that:

 [{"products":[{"id":1,"title":"Apple Pie"}]}]

out of that I need:

[{"id":1,"title":"Apple Pie"}]
about 4 years ago · Santiago Trujillo
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