Created
November 18, 2018 13:27
-
-
Save productioncoder/6849e056950de21cff01a3732b01b290 to your computer and use it in GitHub Desktop.
Youtube in React: fetching trending videos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
class Trending extends React.Component { | |
/* ... */ | |
componentDidMount() { | |
this.fetchTrendingVideos(); | |
} | |
componentDidUpdate(prevProps) { | |
if (prevProps.youtubeLibraryLoaded !== this.props.youtubeLibraryLoaded) { | |
this.fetchTrendingVideos(); | |
} | |
} | |
fetchTrendingVideos() { | |
if (this.props.youtubeLibraryLoaded) { | |
this.props.fetchMostPopularVideos(20, true); | |
} | |
} | |
/* ... */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment