What is the arrow function in React? How is it used?
Arrow functions is a convenient use of brief syntax for writing a function expression. They are also called fat arrow‘ (referring to the
=>`) functions. These functions are bound to the context of their components, important to note since in ES6 auto binding is not available by default. Arrow functions are most useful while working with higher-order functions.
JAVASCRIPT
1// General way
2render() {
3 return(
4 <MyInput onChange={this.handleChange.bind(this) } />
5 );
6}
7// With Arrow Function
8render() {
9 return(
10 <MyInput onChange={ (e) => this.handleOnChange(e) } />
11 );
12}