What does the notation () => mean and how to use it?

I saw this piece of code in React, for example

connect(mapStateToProps, { test: () => {return { type: 'TEST_ACTION' }} })(Index); 

but I could not explain any explanation to Google. The question is probably a dumb question, but I appreciate any help, perhaps links to some existing explanations or examples.

+6
source share
1 answer

This is a function with the arrow ES2015 (aka ES6). This is a function expression that inherits this (and arguments and several other things) from the context in which it was created. So basically:

 test: function() { return { type: 'TEST_ACTION' }; } 

... but using a new syntax that would handle this differently if it used this .

+8
source

All Articles