Created
December 10, 2017 17:28
-
-
Save smitch88/98feffbc26a103c1833ea89c0c9fc12e to your computer and use it in GitHub Desktop.
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
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