From f8782083ccabe0b2dd3a70755054b18caaddc426 Mon Sep 17 00:00:00 2001 From: desmondsow Date: Sun, 12 Jun 2022 19:59:01 +0800 Subject: [PATCH] Fix #2777: Check if `globalFilter` is not null because triggering filter (#2986) ###Defect Fixes Fix #2777: Check if `globalFilter` is not null because triggering filter Check if `globalFilter` is not null because triggering filter in React 18 StrictMode when double-invoking effects (mount -> unmount -> mount) --- components/lib/datatable/DataTable.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/lib/datatable/DataTable.js b/components/lib/datatable/DataTable.js index 3222bd4d7e..12fecd1828 100644 --- a/components/lib/datatable/DataTable.js +++ b/components/lib/datatable/DataTable.js @@ -1295,7 +1295,9 @@ export const DataTable = React.forwardRef((props, ref) => { }, [props.responsiveLayout]); useUpdateEffect(() => { - filter(props.globalFilter, 'global', 'contains'); + if (props.globalFilter) { + filter(props.globalFilter, 'global', 'contains'); + } }, [props.globalFilter]); useUnmountEffect(() => {