MCPcopy Create free account
hub / github.com/codemistic/Web-Development / NewExpense

Function NewExpense

src/components/NewExpense/NewExpense.js:6–36  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

4import './NewExpense.css';
5
6const NewExpense = (props) => {
7 const [Form,updateForm]=useState(false);
8 const saveExpenseDataHandler = (enteredExpenseData) => {
9 const expenseData = {
10 ...enteredExpenseData,
11 id: Math.random().toString()
12 };
13 props.onAddExpense(expenseData);
14 updateForm(false);
15 };
16 function clickHandler(){
17 updateForm((preValue)=>{
18 return !preValue;
19 })
20 }
21 function cancelClick(){
22 updateForm(false);
23 }
24
25
26
27 return (
28 <div className='new-expense'>
29
30 {!Form?<button type="submit" onClick={clickHandler} >Add Expense</button>:null}
31
32 {Form?<ExpenseForm cancelClick={cancelClick} onSaveExpenseData={saveExpenseDataHandler} />:null}
33
34 </div>
35 );
36};
37
38export default NewExpense

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected