我已经开始学习 React 并拥有以下组件:
import React, { Component } from 'react';
class Test extends Component{
handler(){
console.log(this);
return function(){
console.log(this);
}
}
render(){
{this.handler()()}
return null;
}
}
export default Test;
当这个组件安装在浏览器中时,控制台会打印出thishandler返回的函数内未定义。
如果组件已经安装,我不明白为什么它是未定义的。你们能帮我找到原因和可能的更正吗?
谢谢!