Skip to content

Commit 56ffc7d

Browse files
fix: enable list to render when type a search term (#4784)
1 parent c802a57 commit 56ffc7d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/dataExplorer/components/MeasurementSelector.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {FC, useContext, useMemo, useState} from 'react'
1+
import React, {FC, useCallback, useContext, useMemo, useState} from 'react'
22

33
// Components
44
import {ComponentStatus} from '@influxdata/clockface'
@@ -36,9 +36,12 @@ const MeasurementSelector: FC = () => {
3636
const {measurements, loading} = useContext(MeasurementsContext)
3737
const [searchTerm, setSearchTerm] = useState('')
3838

39-
const handleSelect = (option: string): void => {
40-
selectMeasurement(option)
41-
}
39+
const handleSelect = useCallback(
40+
(option: string): void => {
41+
selectMeasurement(option)
42+
},
43+
[selectMeasurement]
44+
)
4245

4346
const handleChangeSearchTerm = (value: string) => {
4447
setSearchTerm(value)
@@ -67,7 +70,14 @@ const MeasurementSelector: FC = () => {
6770
/>
6871
</div>
6972
)
70-
}, [selectedBucket, selectedMeasurement, measurements, loading])
73+
}, [
74+
selectedBucket,
75+
selectedMeasurement,
76+
measurements,
77+
loading,
78+
searchTerm,
79+
handleSelect,
80+
])
7181
}
7282

7383
export default MeasurementSelector

0 commit comments

Comments
 (0)