File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/ui/components/pages/Home/ChannelRenderer/ChannelVideos Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react' ;
1
+ import React , { useEffect , useRef } from 'react' ;
2
2
import { Box , Grid } from '@mui/material' ;
3
3
import { HomeView , Video } from 'types' ;
4
4
import VideoCard from './VideoCard' ;
@@ -29,8 +29,16 @@ function ChannelVideos(props: ChannelVideosProps) {
29
29
onVideoPlay,
30
30
onLoadMore,
31
31
} = props ;
32
+ const showSkeletons = useRef ( true ) ;
32
33
const skeletonNumber = Math . min ( maxResults - videos . length , itemsPerRow ) ;
33
34
35
+ useEffect ( ( ) => {
36
+ if ( ! isLoading ) {
37
+ showSkeletons . current = hasMore ?? true ;
38
+ }
39
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40
+ } , [ isLoading ] ) ;
41
+
34
42
return (
35
43
< Box sx = { { display : 'flex' , pl : 6 } } >
36
44
< Grid container spacing = { config . gridSpacing } columns = { config . gridColumns } >
@@ -39,7 +47,7 @@ function ChannelVideos(props: ChannelVideosProps) {
39
47
< VideoCard video = { video } view = { view } onVideoPlay = { onVideoPlay } />
40
48
</ GridItem >
41
49
) ) }
42
- { isLoading && hasMore && skeletonNumber > 0
50
+ { isLoading && showSkeletons . current && skeletonNumber > 0
43
51
? Array . from ( new Array ( skeletonNumber ) ) . map ( ( _ , index : number ) => (
44
52
< GridItem key = { index } >
45
53
< VideoSkeleton />
You can’t perform that action at this time.
0 commit comments