1

I am just learning Spring react, I don't know Javascript very well. I got to code:

componentDidMount: function () {
    client({method: 'GET', path: '/api/employees'}).done(response => {
        this.setState({employees: response.entity._embedded.employees});
    });

There is written:

componentDidMount is the API invoked after React renders a component in the DOM.

I was looking for what Javascript operator => means. But don't found anything.

Petr F.
  • 161
  • 1
  • 11

1 Answers1

1

This is an arrow function.

An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions and lexically binds the this value (does not bind its own this, arguments, super, or new.target). Arrow functions are always anonymous.

You can see a simple example:

var vec = ['a', 'ab', 'abc'];

var test = vec.map(i => i.length);

alert(test); // 1,2,3
PRVS
  • 1,612
  • 4
  • 38
  • 75
  • 1
    I think this is a poor answer without showing the previous/expanded/old method of writing anonymous functions (which the arrow function is a shortcut of) In this case, var test = vec.map(function (i) { return i.length; }); – Manachi Mar 12 '17 at 08:00
  • A more detailed response is https://stackoverflow.com/questions/24900875/whats-the-meaning-of-an-arrow-formed-from-equals-greater-than-in-javas – Victor Jul 23 '19 at 12:23