I am new to react and working on some exercises. Inside YTSearch when I am using this, i get a message that this is undefined. But the tutorial instructor which i am looking at has the same code and it is working for him. Can someone help?
import React, { Component } from 'react';
import ReactDOM from 'react-dom'
import YTSearch from 'youtube-api-search';
const API_KEY = "AIzaSyCDclF-xo-YjMt48H8WMsnebncKmU3jsQA";
class App extends Component {
constructor(props){
super(props);
this.state = { 'videos' : []};
YTSearch({ key: API_KEY, term: 'surfboards'}, function(data){
console.log(data);
console.log(this);
});
}
render(){
return <input />;
}
}
ReactDOM.render(<App />, document.querySelector('.container'))