Skip to content

Commit 43c932c

Browse files
committed
refresh filter text on changes
1 parent 2a46a58 commit 43c932c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/components/ui/FilterTextField.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useState, useEffect } from 'react';
22

33
import IconButton from '@material-ui/core/IconButton';
44
import InputAdornment from '@material-ui/core/InputAdornment';
@@ -38,16 +38,14 @@ function FilterTextField({
3838
const filterOptions = fuzzySearch(newValue, options, minScore, optionsKey);
3939
onChangeOptions(filterOptions);
4040
}, DEBOUNCE_WAIT);
41-
const onChange = (event) => {
42-
setValue(event.target.value);
43-
const newValue = event?.target?.value;
44-
onFilter(newValue);
45-
};
41+
const onChange = (event) => setValue(event.target.value);
4642
const onReset = () => {
4743
setValue('');
4844
onFilter('');
4945
};
50-
46+
useEffect(() => {
47+
onFilter(value);
48+
}, [onFilter, value, options]);
5149
return (
5250
<TextField
5351
placeholder="Search"

0 commit comments

Comments
 (0)