我是React开发的新手......这是我写过的代码
constructor(props) {
super(props);
this.state = { videos: [] };
YTSearch({ key: API_KEY, term: 'Led zeppelin'}, function(videos) {
this.setState({ videos });
});
}
但在运行时我将此错误发送到控制台
proxyConsole.js:56 TypeError: Cannot read property 'setState' of undefined
at index.js:17
at index.js:19
at <anonymous>
&#34; this &#34;变量是 null ..为什么?我怎样才能访问this.setState ??
答案 0 :(得分:1)
cell.baseview.isUserInteractionEnabled = true
试试这个