Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
React mapping ERROR: Cannot read properties of undefined (reading 'toLocaleString')

Im trying to map the list of my expense array elements and after using the map() method Im getting the error "Uncaught TypeError: Cannot read properties of undefined (reading 'toLocaleString')". I couldn't find the issue please check the code link - https://github.com/mohitdevelops/react-lessons/tree/main/toLocalString-issue

Please help me out, I'm stuck in this error for days.

And checkout the screenshot here ๐Ÿ‘‡

enter image description here

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

You're using the wrong object keys in your expenseData object in the ExpenseForm component. And so the date will "always" be undefined thus failed during the date conversion in your ExpenseDate component. To fix this, you just need to supply the correct object:

From this:

const expenseData = {
    inputValue: enteredValue,
    inputAmount: enteredAmount,
    inputDate: new Date(enteredDate),
};

To this:

const expenseData = {
    id: "e5", // You will need to figure out a way to create a dynamic ID here :)
    title: enteredValue,
    amount: enteredAmount,
    date: new Date(enteredDate),
};
about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!