Skip to content

Instantly share code, notes, and snippets.

@productioncoder productioncoder/Watch.js
Last active Dec 18, 2018

Embed
What would you like to do?
Youtube in React: wiring up action creators with Watch component
/* ... */
export class Watch extends React.Component {
/* ... */
componentDidMount() {
if (this.props.youtubeLibraryLoaded) {
this.fetchWatchContent();
}
}
componentDidUpdate(prevProps) {
if(this.props.youtubeLibraryLoaded !== prevProps.youtubeLibraryLoaded) {
this.fetchWatchContent();
}
}
fetchWatchContent() {
const videoId = this.getVideoId();
if(!videoId) {
this.props.history.push('/');
}
this.props.fetchWatchDetails(videoId, this.props.channelId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.