I watched the Redux application on the Internet and saw the following code there:

function mapStateToProps(state) { const { value } = state.counter; return { value }; } export default connect(mapStateToProps)(ReduxCounter); 

ReduxCounter is a react-component. Memory prompts that in JS 2 the line is written in ECMA 6 and this is equivalent to:

 const value = state.counter.value; 

but the question is in the returned result, which is also enclosed in curly braces return { value }; ??

And the second question - how to understand the record connect(mapStateToProps)(ReduxCounter) ? Interested in the sequence of actions in clear language.

    1 answer 1

    return { value }; - it's like return {value: value};

    connect(mapStateToProps)(ReduxCounter) : The connect(mapStateToProps) function returns another function that is immediately called with arguments (ReduxCounter)

     function a(){ return function(value){ return {value} } } console.log( a()(2) )