Skip to content

Commit

Permalink
Fix #2777: Check if globalFilter is not null because triggering fil…
Browse files Browse the repository at this point in the history
…ter (#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)
  • Loading branch information
desmondsow authored Jun 12, 2022
1 parent d838b83 commit f878208
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit f878208

Please sign in to comment.