-
-
Save Ateevduggal/853c4831eaaf88185ba4445e5ba63578 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Change = (e) => { | |
const { name, value } = e.target; | |
setNewData({ ...newData, [name]: value }); | |
}; | |
const Add = (e) => { | |
e.preventDefault(); | |
setTableData([...tableData, { ...newData, id: Math.random() }]); // for giving the new data some random id | |
setNewData({ | |
// for enptying the form | |
fullName: "", | |
userName: "", | |
address: "", | |
phoneNumber: "", | |
email: "", | |
website: "", | |
companyName: "", | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment