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

211
Visualizações
TypeError: Cannot destructure property 'reflectionId' of 'undefined' as it is undefined

I have a deeply nested object and I'm trying to get a specific value from it. On my development and production environment, the function returns the error above (TypeError: Cannot destructure property 'reflectionId' of 'undefined' as it is undefined.) However, I am unable to debug this, and when I put in the exact same object and function into a code sandbox, it works fine.

I have recreated my object and code in a codesandbox here: https://codesandbox.io/s/nameless-bird-rknxrr?file=/src/index.js:28281-28461 (check the console to see the working output)

const discordLink = CHARACTER_MAP
  .flatMap((character) => character.chapters)
  .find(({ reflectionId }) => reflectionId === reflectionNum).discordLink;

What could the problem be? The flatMap returns a properly formatted object (checked that). reflectionId is the property name I am looking for, and it seems correctly defined in both my live code and the sandbox. Based on how .find() is described in [the Mozilla docs] 1 it seems like I'm using the "Using arrow function and destructuring" method properly too. It's most puzzling that it works in codesandbox but not in live.

Error message

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try this :

const discordLink = CHARACTER_MAP
  .flatMap((character) => character.chapters)
  .find((reflection) => reflection.reflectionId === reflectionNum).discordLink
about 4 years ago · Juan Pablo Isaza Relatório
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