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

356
Visualizações
TypeError: Cannot read properties of undefined (reading 'toISOString')

enter image description here

import './ExpenseItem.css';

function ExpenseItem(props){

return (
    <div className="expense-item">
        <div>{props.date.toISOString()}</div>
        <div className="expense-item__description">
            <h2>{props.title}</h2>
            <div class="expense-item__price">${props.amount}</div>
        </div>
    </div>
)
}

export default ExpenseItem;

TypeError: Cannot read properties of undefined (reading 'toISOString')

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

0

It will give this error because your props.date is undefined and you can not call toISOString in undefined.

So, please check why props.date field is undefined, and if the case is related to API calling or asynchronous then go with the optional chaining solution, or if it is not supported then go with the regular flow.

Optional Chaining

<div>{props.date?.toISOString()}</div>

Regular

<div>{props.date ? props.date.toISOString() : null}</div>
about 4 years ago · Juan Pablo Isaza Relatório

0

Looks like either props or props.date is undefined. undefined does not have a methodtoISOString. Thus calling this function throws an error.

Make sure that you pass in correct props in your parent Component.

about 4 years ago · Juan Pablo Isaza Relatório

0

I had the same issue. The problem was actually in the App.js file I wrote the wrong syntax of ExpenseItem. There fore you should check that you include the props in the ExpenseItem tag, not outside, not beetween! Example <ExpenseItem "THE PROPS" >

<ExpenseItem
    title={expenses[0].title}
    amount={expenses[0].amount}
    date={expenses[0].date}
  ></ExpenseItem>
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