File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ class Mentor extends Component {
99 constructor ( props ) {
1010 super ( props ) ;
1111 this . state = {
12- Product : [ ]
12+ Product : [ ] ,
13+ showProducts : 10 ,
14+ isLoading : false
1315 }
1416 }
1517
@@ -36,15 +38,26 @@ class Mentor extends Component {
3638 });*/
3739 }
3840
41+ loadMore = ( ) => {
42+ this . setState ( { isLoading : true } )
43+ setTimeout ( ( ) => {
44+ this . setState ( ( prevState ) => ( { isLoading : false , showProducts : prevState . showProducts + 10 } ) )
45+ } , 3000 )
46+ clearTimeout ( )
47+ }
48+
3949 getSearchedProducts ( ) {
4050 const { search } = this . props ;
41- return search ? this . state . Product . filter (
51+ const { showProducts } = this . state
52+ const productList = search ? this . state . Product . filter (
4253 ( data ) => data . name . toLowerCase ( ) . indexOf ( search . toLowerCase ( ) ) !== - 1
4354 ) : this . state . Product ;
55+ return productList . slice ( 0 , showProducts )
4456 }
4557
4658
4759 render ( ) {
60+ const { isLoading } = this . state
4861 return (
4962 < div className = "main thememain-white" >
5063 < div className = "container content-main" >
@@ -54,6 +67,9 @@ class Mentor extends Component {
5467 return < MentorList key = { data . id } data = { data } />
5568 } ) }
5669 </ div >
70+ < div className = "loadMore" >
71+ < button onClick = { this . loadMore . bind ( this ) } > { isLoading ? "Loading" : "Load More" } </ button >
72+ </ div >
5773 </ div >
5874 </ div >
5975
Original file line number Diff line number Diff line change @@ -228,3 +228,11 @@ body {
228228.whiteColor {
229229 color : white !important ;
230230}
231+
232+ .loadMore button {
233+ background : linear-gradient (165deg , # 6e60cc, # 484389 );
234+ color : white;
235+ width : 60vh ;
236+ padding : 20px ;
237+ margin : 20px auto;
238+ }
You can’t perform that action at this time.
0 commit comments