File tree 1 file changed +11
-9
lines changed
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react' ;
2
2
import ReactDOM from 'react-dom' ;
3
+ import _ from 'lodash' ;
3
4
import YTSearch from 'youtube-api-search' ;
4
5
import SearchBar from './components/search_bar' ;
5
6
import VideoList from './components/video_list' ;
@@ -31,15 +32,16 @@ class App extends Component {
31
32
}
32
33
33
34
render ( ) {
34
- return (
35
- < div >
36
- < SearchBar handleSearchTermChange = { term => this . videoSearch ( term ) } />
37
- < VideoDetail video = { this . state . selectedVideo } />
38
- < VideoList
39
- handleVideoSelect = { selectedVideo => this . setState ( { selectedVideo } ) }
40
- videos = { this . state . videos } />
41
- </ div >
42
- ) ;
35
+ const videoSearch = _ . debounce ( ( term ) => { this . videoSearch ( term ) } , 300 ) ;
36
+ return (
37
+ < div >
38
+ < SearchBar handleSearchTermChange = { videoSearch } />
39
+ < VideoDetail video = { this . state . selectedVideo } />
40
+ < VideoList
41
+ handleVideoSelect = { selectedVideo => this . setState ( { selectedVideo } ) }
42
+ videos = { this . state . videos } />
43
+ </ div >
44
+ ) ;
43
45
}
44
46
} ;
45
47
You can’t perform that action at this time.
0 commit comments