Saturday, October 8, 2022

React: Sending data to siblings

 1.React form component

2.calling above compoent



note: passing data to sibling.

---------------------------------

 NewExpense.js file:  

<ExpenseForm onSaveExpenseData={onSaveExpenseDataHandler}></ExpenseForm>

---------------------------------

ExpenseForm.js: 

 props.onSaveExpenseData(expenseData); // calling one js file to other(newexpense.js)

 setEnteredTitle("");

 setEnteredAmount("");

 setEnteredDate("");  

};

---------------------------------

calling expenseform in app.js

 for appending form data to app.js file arr.

pushing data to parent node

props.onAddExpense(expenseData)  // lifting up date to parent app.js





No comments:

Post a Comment