I'm new in React development.. this is the code I've wrote
constructor(props) {
super(props);
this.state = { videos: [] };
YTSearch({ key: API_KEY, term: 'Led zeppelin'}, function(videos) {
this.setState({ videos });
});
}
but when running i've this error into the console
proxyConsole.js:56 TypeError: Cannot read property 'setState' of undefined
at index.js:17
at index.js:19
at <anonymous>
the "this" variable is null.. why? How can i access to this.setState ??