- Add useDebounce hook for future search optimization - Integrate LoadingState, ErrorState, RefreshControl, and PaginationLoader into searchResults.tsx - Add pull-to-refresh functionality with RefreshControl component - Implement pagination with loadMore and PaginationLoader - Add error handling with retry functionality using ErrorState - Update SearchResultsGrid to support refreshControl, onEndReached, and ListFooterComponent props - Add scroll event handling for pagination trigger - Add TODO comment in searchWorksResults.tsx for backend API integration - Reduce initial search limit from 50 to 20 for better performance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
18 lines
384 B
TypeScript
18 lines
384 B
TypeScript
import { useEffect, useState } from 'react'
|
|
|
|
export function useDebounce<T>(value: T, delay: number = 500): T {
|
|
const [debouncedValue, setDebouncedValue] = useState<T>(value)
|
|
|
|
useEffect(() => {
|
|
const handler = setTimeout(() => {
|
|
setDebouncedValue(value)
|
|
}, delay)
|
|
|
|
return () => {
|
|
clearTimeout(handler)
|
|
}
|
|
}, [value, delay])
|
|
|
|
return debouncedValue
|
|
}
|