Loading…

What are arrow functions? How are they used?

Arrow functions, also called ‘fat arrow‘ (=>), are brief syntax for writing the expression. These functions bind the context of the components because auto binding is not available by default in ES6. Arrow functions are useful if you are working with the higher order functions.

Example

                                        

//General way

render() {

return(

<MyInput onChange={this.handleChange.bind(this) } />

);

}

//With Arrow Function

render() {

return(

<MyInput onChange={ (e) => this.handleOnChange(e) } />

);

}

Suggest An Answer

No suggestions avaliable!

Latest post from React js interview questions

Ask Question