The Error for using reduce

Hi every one

I code a table component like this:

when I run the project face this error:

this is the file of the project:

I dont know how to solve it so, i will be appreciate if you could help

1 Like

Probably depends on the data itself, i think your storing the expenses in an array which can’t directly be reduced so you have to wrap expense.amount in a parseFloat so that it will stringify it and return a number.

=> acc + parseFloat(expense.amount)

although looking back it looks like it has an array and an object inside there, so you may have to not put the id there or store 2 seperate useStates if you want to keep all that info, for example setExpensesArr and setExpensesObj then choose then if you want the id attached, pass your data through reduce then append it to the end

1 Like

I’ve run your code and it is working fine. Maybe you need to restart your server (kill and run npm run dev again)?

In my experience, Vite sometimes doesn’t refresh its builds and restarting the dev server is needed.

1 Like

Okay we’ll help you out

yeah, the error just disappear with no reason. thanks

1 Like