Overview
ThePokeGallery component provides a complete Pokemon browsing experience with search, filtering by type and region, sorting options, view mode toggling (grid/table), and pagination. It manages complex state through custom hooks and Zustand stores.
Import
Props
Array of Pokemon summary data to display in the gallery
Custom message to display when no Pokemon match the current filters (optional)
Usage Example
Features
Search and Filtering
The gallery uses theusePokeFilters hook with debouncing (250ms) to provide:
- Text Search: Filter Pokemon by name
- Region Filter: Filter by generation/region (Kanto, Johto, etc.)
- Type Filter: Multi-select type filtering
- Sort Options: Multiple sorting criteria
Pagination
TheusePaginate hook handles pagination logic:
- 24 Pokemon per page
- Next/Previous navigation
- Direct page selection
- Automatic page count calculation
View Modes
Supports two display modes stored in Zustand:- Grid View: Pokemon cards in a responsive grid layout
- Table View: Compact table format for quick browsing
Hydration Handling
The component shows a skeleton loader until client-side hydration is complete:State Management
Filter State
Managed byusePokeFilters hook:
Pagination State
Managed byusePaginate hook:
View Preference
Stored globally in Zustand:Component Structure
Performance Considerations
Debounced Search
Search input is debounced by 250ms to prevent excessive filtering operations during typing.Lazy Rendering
Only Pokemon on the current page are rendered (24 at a time), improving performance for large datasets.Skeleton Loading
Shows placeholder content during hydration to prevent layout shift.Empty States
When no Pokemon match the current filters, the component displays a centered message:Related Components
- PokemonCard - Individual card display
- FilterBar - Filter control UI
- PaginationControl - Pagination UI
- PokemonTable - Table view display
Custom Hooks Used
usePokeFilters- Filtering and sorting logicusePaginate- Pagination logicuseHydrated- Client-side hydration detectionuseTweaksStore- Global view preference
Source Location
/src/components/pokemon/PokeGallery.tsx:1-86