parent
72e459f3e2
commit
e51dbefd0a
|
@ -28,14 +28,14 @@ export const DiscoverFeedsScreen = withAuthRequired(
|
||||||
const [isInputFocused, setIsInputFocused] = React.useState<boolean>(false)
|
const [isInputFocused, setIsInputFocused] = React.useState<boolean>(false)
|
||||||
const [query, setQuery] = React.useState<string>('')
|
const [query, setQuery] = React.useState<string>('')
|
||||||
const debouncedSearchFeeds = React.useMemo(
|
const debouncedSearchFeeds = React.useMemo(
|
||||||
() => debounce(() => feeds.search(query), 200), // debouce for 200 ms
|
() => debounce(query => feeds.search(query), 500), // debounce for 500ms
|
||||||
[feeds, query],
|
[feeds],
|
||||||
)
|
)
|
||||||
const onChangeQuery = React.useCallback(
|
const onChangeQuery = React.useCallback(
|
||||||
(text: string) => {
|
(text: string) => {
|
||||||
setQuery(text)
|
setQuery(text)
|
||||||
if (text.length > 1) {
|
if (text.length > 1) {
|
||||||
debouncedSearchFeeds()
|
debouncedSearchFeeds(text)
|
||||||
} else {
|
} else {
|
||||||
feeds.refresh()
|
feeds.refresh()
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,9 @@ export const DiscoverFeedsScreen = withAuthRequired(
|
||||||
feeds.refresh()
|
feeds.refresh()
|
||||||
}, [feeds])
|
}, [feeds])
|
||||||
const onSubmitQuery = React.useCallback(() => {
|
const onSubmitQuery = React.useCallback(() => {
|
||||||
feeds.search(query)
|
debouncedSearchFeeds(query)
|
||||||
}, [feeds, query])
|
debouncedSearchFeeds.flush()
|
||||||
|
}, [debouncedSearchFeeds, query])
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
React.useCallback(() => {
|
React.useCallback(() => {
|
||||||
|
|
Loading…
Reference in New Issue