Skip to content

Instantly share code, notes, and snippets.

@Ateevduggal
Created Jun 11, 2022
Embed
What would you like to do?
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