Skip to content

Instantly share code, notes, and snippets.

@Ateevduggal
Created June 11, 2022 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ateevduggal/853c4831eaaf88185ba4445e5ba63578 to your computer and use it in GitHub Desktop.
Save Ateevduggal/853c4831eaaf88185ba4445e5ba63578 to your computer and use it in GitHub Desktop.
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