Arrow Functions in React
This lesson demonstrates the uses of Arrow Functions in React.
We'll cover the following...
As mentioned in the previous lesson, Arrow Functions are a more concise way of writing a function in JavaScript. They are frequently used in React to make things more efficient and simpler (Event Handling, preventing bugs, etc.).
When teaching someone about React, I explain JavaScript arrow functions pretty early. They are one of JavaScript’s language additions in ES6 which pushed JavaScript forward in functional programming.
Press + to interact
// JavaScript ES5 functionfunction getGreetingFunc() {return 'Welcome to JavaScript';}// JavaScript ES6 arrow function with bodyconst getGreetingArrow1 = () => {return 'Welcome to JavaScript';}// JavaScript ES6 arrow function without body and implicit returnconst getGreetingArrow2 = () =>'Welcome to JavaScript';console.log(getGreetingFunc());console.log(getGreetingArrow1());console.log(getGreetingArrow2());
...
Access this course and 1400+ top-rated courses and projects.