const handleTestDelete = (id: any) => {
deleteTest(id).then(() => {
queryClient.invalidateQueries("test");
});
};
const columns = useMemo(
() => [
{ field: "id", headerName: "ID", width: 80 },
{
field: "",
width: 120,
disableClickEventBubbling: true,
sortable: false,
disableColumnMenu: true,
renderCell: (cell: any) => (
<>
<IconButton
aria-label="delete"
onClick={() => handleTestDelete(cell.id)}
>
<DeleteIcon fontSize="small" />
</IconButton>
<IconButton
aria-label="view"
onClick={() => history.push(`/something/${cell.id}/details`)}
>
<VisibilityIcon fontSize="small" />
</IconButton>
</>
),
},
],
[history]
I am getting this warning
React Hook useMemo has a missing dependency: 'handleTestDelete'. Either include it or remove the dependency array.
because I am not adding the function called on click of the delete button in dependencies ... why should I put it as a dependency? I'm not even sure if putting history as a dependency is correct; I don't think columns need to be reevaluated when chronology changes
I was wrong?
Thank you