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

148
Vistas
"TypeError: Cannot read properties of undefined (reading '0')" when accessing data from an array in React while retrieving data from react/redux

I am getting a weird error while using React and Redux

I access data from redux state using the following code:

const aboutGet = useSelector((state) => state.aboutGet);
const { loading, error, aboutData } = aboutGet;
console.log(aboutData); 

The output of the above is the console output as follows:

    [{…}]
    0:
    aboutcontent: "Test Data"
    createdAt: "2021-09-19T08:59:01.548Z"
    image: "Some Image"
    title: "Some new About"
    updatedAt: "2021-09-20T03:04:09.014Z"
    __v: 0
    _id: "6146fbd5f4720923359e3338"
    [[Prototype]]: Object
    length: 1

I now start by trying to access the _id from the above by using the following lines of code:

const aboutId = aboutData[0]._id;
console.log(aboutId);

This gives me the following error:

"TypeError: Cannot read properties of undefined (reading '0')"

Can someone please help and let me know where I am going wrong and what I need to do to access the data inside aboutData.

Many thanks and regards Teejay

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