-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
52 lines (43 loc) · 1.14 KB
/
App.js
File metadata and controls
52 lines (43 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React,{useState} from "react";
import './App.css';
import ExpenseItem from "./components/Expenses/ExpenseItem";
import Expenses from "./components/Expenses/Expenses";
import NewExpense from "./components/NewExpense/NewExpense";
const DUMMY_EXPENSES= [
{
id: 'e1',
title: 'Toilet Paper',
amount: 94.12,
date: new Date(2020, 7, 14),
},
{id: 'e2', title: 'New TV', amount: 799.49, date: new Date(2021, 2, 12)},
{
id: 'e3',
title: 'Car Insurance',
amount: 294.67,
date: new Date(2021, 2, 28),
},
{
id: 'e4',
title: 'New Desk (Wooden)',
amount: 450,
date: new Date(2021, 5, 12),
},
];
const App =() =>{
const [expenses,setExpenses]= useState(DUMMY_EXPENSES)
const addExpenseHandler=expense=>{
setExpenses((prevExpenses) =>{
return [expense,...prevExpenses]
})
}
return (
<div>
<body className="body">
<NewExpense onAddExpense={addExpenseHandler}/>
<Expenses items={expenses}/>
</body>
</div>
);
}
export default App;