feat: integrate UI components into Search pages with pagination and loading
- 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>
This commit is contained in:
17
hooks/use-debounce.ts
Normal file
17
hooks/use-debounce.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user