Created
April 3, 2019 05:30
-
-
Save kawnayeen/7aaaeab1029fd057c8eedf1b9efab05d to your computer and use it in GitHub Desktop.
Enhanced Youtube # 6 - Show selected video at video details
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
// at app.js -- write a call back to update selectedVideo & provide that as props at VideoList | |
onVideoSelect={selectedVideo => this.setState({selectedVideo})} | |
// at video.list.js -- extract the callback from props and send that to VideoListItem | |
const onVideoSelect = props.onVideoSelect; | |
const videoList = videos.map( v => <VideoListItem onVideoSelect={onVideoSelect} key={v.etag} video={v} />); | |
// at video.list.item.js -- call the call back | |
const VideoListItem = ({video, onVideoSelect}) | |
<li className="list-group-item" onClick={() => onVideoSelect(video)}> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment