2

So I'm trying to get a bit better with CS concepts. Going over the concept of currying. This seems to be pretty similar to what is going on with redux/react when you connect. Is it correct to call this currying? If I understand correctly, connect returns a second function which then takes App as an argument.... that's currying, right?

(Take pity on me, I'm trying to understand the concept)

const mapStateToProps = state => ({
  results: state.results ? state.results.items : []
}); 

export default connect(mapStateToProps)(App);
J Seabolt
  • 2,576
  • 5
  • 25
  • 57
  • 1
    Yes, the connect function is indeed an example of a curried function. Reference this question for more insight: https://stackoverflow.com/questions/36314/what-is-currying?rq=1 – kingdaro Mar 02 '18 at 22:51

1 Answers1

1

Not quite.

I'm willing to be wrong about this, but a curried function will return a function that accepts the remaining arguments when invoked with fewer than the required number of arguments.

connect() is not curried by default. This means invoking it without any arguments does not produce a partially applied function. Instead, it will give you a valid higher-order component that provides dispatch to your component.

Danny Delott
  • 6,756
  • 3
  • 33
  • 57