Arrow functions are more of brief syntax for writing the function expression. They are also called ‘fat arrow‘ (=>) functions. These functions allow to bind the context of the components properly since in ES6 auto binding is not available by default. Arrow functions are mostly useful while working with the higher order functions.
//General way
render() {
return(
<MyInput onChange=
{this.handleChange.bind(this) } />
);
}
//With Arrow Function
render() {
return(
<MyInput onChange
={ (e) => this.handleOnChange(e) } />
);
}
Comments
Post a Comment