I have started learning React and have below component:
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;
When this component is mounted in browser, the console prints thatthis inside the function returned by handler is undefined.
I don't understand why it is undefined if the component has already mounted. Can you people help me to find the reason for this and a possible correction.
thank You!