Parenthesis after function call

Hello does anybody knows what the following syntax means?

const List = connect(mapStateToProps) (ConnectedList);

Notice the space after the function call.

This is an excerpt from this Redux tutorial

Connect return a wrapper function.
This means that calling connect returns a function that expects to be called again with a component to enhance as argument.

This technique is called currying in computer science (super cool to be honest), and is the act of evaluating functions with multiple arguments into sequence of functions with a single argument.

So the parenthesis after the function call is to call the function again with another argument.
The sane could have been splitted into two different calls:

const connectSomething = connect(state, props);

const connectedComponent = connectSomething(MyComponent);

The space in between is meaningless.

More detailed explanation and examples on the official redux documentation.

1 Like