I am trying to deploy my react application and its not rendering the page properly, It is throwing the below error : react-dom.production.min.js:216 TypeError: Object(…) is not a function.
I have linked the screenshot of the error and the file name along with my github link of the repo.[![
JavaScript
x
42
42
1
Expense.js
2
3
import { useState } from "react";
4
import "../css/Expenses.css";
5
import Card from "./Card";
6
import ExpenseItem from "./ExpenseItem";
7
import Filter from "./Filter";
8
9
function Expenses(props){
10
let data = props.data;
11
let [year,changeYear] = useState("2021");
12
13
let data2 = data.filter(function(item){
14
return(new Date(item.dates).getFullYear().toString() === year);
15
})
16
17
18
let setFilter = function(yearValue){
19
changeYear(yearValue);
20
}
21
22
23
return(
24
<Card className = "card">
25
<div className="filter-section">
26
<h3>Filter By Year</h3>
27
<Filter sendData={setFilter} yearVal = {year} className='year-filter-card'/>
28
</div>
29
<div className="expense-wrap">
30
{data2.length?
31
data2.map(function(expItem) {
32
return <ExpenseItem key={Math.random()*100000} item= {expItem} deleteMe={props.deleteMe}/>
33
}):
34
<h2 className="nodata">No Expense Data</h2>
35
}
36
</div>
37
</Card>
38
);
39
40
}
41
42
export default Expenses;
link to my repo: https://github.com/AbhishekTomr/money-tracker
Advertisement
Answer
The issue is resolved now had to use this line:
JavaScript
1
2
1
import React,{ useState } from "react";
2