Skip to content

Commit 0f625ba

Browse files
committed
fix: fix lint error on react hooks
Signed-off-by: Antonette Caldwell <134739862+nebula-aac@users.noreply.github.com>
1 parent e1df70d commit 0f625ba

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/custom/TypingFilter/index.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,32 @@ export function TypingFilter({ filterSchema, handleFilter, autoFilter = false }:
7878
if (!inputFieldRef.current) {
7979
return;
8080
}
81-
81+
82+
const inputField = inputFieldRef.current; // Copy the value to a variable
83+
8284
const handleKeyDown = (e: KeyboardEvent) => {
8385
if (e.key === 'Enter') {
84-
// Perform nullish check before accessing inputFieldRef.current.value
85-
const inputValue = inputFieldRef.current?.value ?? '';
86+
// Perform nullish check before accessing inputField.value
87+
const inputValue = inputField?.value ?? '';
8688
handleFilter(getFilters(inputValue, filterSchema));
8789
setAnchorEl(null);
8890
}
8991
};
90-
91-
inputFieldRef.current?.addEventListener('keydown', handleKeyDown);
92-
92+
93+
inputField?.addEventListener('keydown', handleKeyDown);
94+
9395
return () => {
94-
inputFieldRef.current?.removeEventListener('keydown', handleKeyDown);
96+
inputField?.removeEventListener('keydown', handleKeyDown);
9597
};
96-
}, []);
98+
}, [filterSchema, handleFilter]);
9799

98100
React.useEffect(() => {
99101
if (autoFilter && filterState.state === FilteringState.SELECTING_FILTER) {
100102
// Perform nullish check before accessing filterState.context
101103
const filterValue = filterState.context?.value ?? '';
102104
handleFilter(getFilters(filterValue, filterSchema));
103105
}
104-
}, [filterState.state]);
106+
}, [filterState.state, autoFilter, filterSchema, filterState.context?.value, handleFilter]);
105107

106108
return (
107109
<React.Fragment>

0 commit comments

Comments
 (0)