Skip to content

Instantly share code, notes, and snippets.

@smitch88
Created December 10, 2017 17:28
Show Gist options
  • Save smitch88/98feffbc26a103c1833ea89c0c9fc12e to your computer and use it in GitHub Desktop.
Save smitch88/98feffbc26a103c1833ea89c0c9fc12e to your computer and use it in GitHub Desktop.
getRelatedVideos(hashtagToFind, videos){
return videos.filter(({ title }) => title.indexOf(hashtag) > -1);
}
componentWillReceiveProps(newProps){
const { hashtag } = this.state.projects;
if(this.props.videos.length !=== newProps.videos.length){
this.setState({ videos: this.getRelatedVideos(hashtag, newProps)})
}
}
render(){
const { projects, videos } = this.state;
....rest of stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment