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

151
Visualizações
"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 à 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