Skip to content

Instantly share code, notes, and snippets.

@saposki
Created November 22, 2016 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saposki/a6f44c3cc1937e9f75c713dfe0eb757f to your computer and use it in GitHub Desktop.
Save saposki/a6f44c3cc1937e9f75c713dfe0eb757f to your computer and use it in GitHub Desktop.
pair programming
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import YTSearch from 'youtube-api-search';
import SearchBar from './components/search_bar';
import VideoList from './components/video_list';
const API_KEY = 'AIzaSyA3EACxxpvIrSqD355X1tKVu0PrmCg05mM';
YTSearch({key: API_KEY, term: 'surfboards'}, function(data){
console.log(data);
});
// Create a new component. This component should produce
//some HTML
class App extends Component {
constructor(props){
super(props);
this.state = { video: [] };
YTSearch({key: API_KEY, term: 'surfboards'}, (videos) => {
this.setState({ videos });
// this.setState({ videos: videos})
});
}
render(){
return (
<div>
<SearchBar />
<VideoList videos={this.state.videos} />
</div>
);
}
}
// Take this component's generaed HTML and put it on the page (in the DOM)
ReactDOM.render(<App />, document.querySelector('.container'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment