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]
我收到此警告
React Hook useMemo 缺少一个依赖项:'handleTestDelete'。包括它或删除依赖数组。
因为我没有在依赖项中添加单击删除按钮时调用的函数......为什么我要把它作为依赖项?我什至不确定将历史作为依赖项是否正确;我认为当年表发生变化时不需要重新评估专栏
我错了?
谢谢