I am trying to call a function inside a class but confused with below syntax.
Why I need to use bind method when calling a function?
Why arrow function is not getting executed?
import React, { Component } from 'react'
import { Text, View } from 'react-native'
//arrow function not getting executed!
myFun = data => {
console.warn(data);
}
myFun(data){
console.warn(data);
}
class Hello extends Component {
render() {
return (
<View>
{this.myFun("first")}
{this.myFun.bind(this, "second")}
</View>
);
}
}
export default Hello;
Note: I have removed comment from the first method!