Skip to content

Instantly share code, notes, and snippets.

@kawnayeen
Created April 3, 2019 05:30
Show Gist options
  • Save kawnayeen/7aaaeab1029fd057c8eedf1b9efab05d to your computer and use it in GitHub Desktop.
Save kawnayeen/7aaaeab1029fd057c8eedf1b9efab05d to your computer and use it in GitHub Desktop.
Enhanced Youtube # 6 - Show selected video at video details
// 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