File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export default function FilmGrid({
1010 currentSearchPage,
1111 totalSearchPages,
1212 loading,
13+ initialLoading = false ,
1314} ) {
1415 const pathname = usePathname ( ) ;
1516 const searchParams = useSearchParams ( ) ;
@@ -45,6 +46,17 @@ export default function FilmGrid({
4546 className = { `relative z-10 mx-auto flex w-full max-w-none flex-col gap-2 @container` }
4647 >
4748 < ul className = "grid grid-cols-3 gap-2 @2xl:grid-cols-4 @5xl:grid-cols-5 @6xl:grid-cols-6 @7xl:grid-cols-7" >
49+ { /* Initial loading */ }
50+ { initialLoading &&
51+ loading &&
52+ [ ...Array ( 20 ) ] . map ( ( _ , i ) => (
53+ < span
54+ key = { i }
55+ className = { `aspect-poster animate-pulse rounded-xl bg-gray-400 bg-opacity-20` }
56+ > </ span >
57+ ) ) }
58+
59+ { /* Results */ }
4860 { films ?. map ( ( film ) => {
4961 return (
5062 < li key = { film . id } >
@@ -56,10 +68,11 @@ export default function FilmGrid({
5668 ) ;
5769 } ) }
5870
59- { ( loading || totalSearchPages > currentSearchPage ) &&
60- [ ...Array ( 20 ) . keys ( ) ] . map ( ( _ , i ) => (
71+ { /* Infinite loading */ }
72+ { ( ! loading && totalSearchPages > currentSearchPage ) &&
73+ [ ...Array ( 20 ) ] . map ( ( _ , i ) => (
6174 < span
62- key = { i }
75+ key = { i + 20 }
6376 ref = { i === 0 ? loadMoreRef : null }
6477 className = { `aspect-poster animate-pulse rounded-xl bg-gray-400 bg-opacity-20` }
6578 > </ span >
You can’t perform that action at this time.
0 commit comments