Skip to content

Instantly share code, notes, and snippets.

@Ateevduggal
Last active June 11, 2022 05:25
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/1cada81ec4290307b576daccd8e5fd61 to your computer and use it in GitHub Desktop.
Save Ateevduggal/1cada81ec4290307b576daccd8e5fd61 to your computer and use it in GitHub Desktop.
const handleEditChange = (e) => {
const { name, value } = e.target;
setEditData({ ...editData, [name]: value });
};
const Save = (e) => {
e.preventDefault();
let filterData = tableData.filter((e) => e.id !== editData.id);
let updatedData = [...filterData, { ...editData }].sort((a, b) =>
a.id > b.id ? 1 : -1
);
setTableData(updatedData);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment