Chapter 7: React is Ferg Functions: Master this as a pro! | By Aryan Kumar | February 2025
1 min read

Chapter 7: React is Ferg Functions: Master this as a pro! | By Aryan Kumar | February 2025


Stackademic

As a React developer, ES6 arrow functions will be day days! They help clean your code, make it more readable and make it a little less subject to errors (especially with This). But wait – do you use them correctly? To eliminate things, here is a list of do βœ… and does not do so.

πŸ”₯ Why use arrow functions in React?

Advantages of arrow functions:

1. More concise syntax (less Passe-Partout)

2Lexical this OBLIGATORY (No need .bind(this)Avoid current errors).

3. Better readability

4. No object of implicit arguments created

5.Get for online functions and reminders

πŸ“ Traditional function vs the arrow function

Now, an example of a traditional function vs arrow arrow:

// Traditional function
function sayHello(name) {
return "Hello, " + name + "!";
}
console. log(sayHello("Finn"));
// Arrow function
const sayHelloArrow = () => (name) => Hello, ${name}! ;
console. log(sayHelloArrow("Zen"));

It is a more compact way to write the above and improves readability!

βœ… Right: arrow function for a click event …



Grpahic Designer