|
|
|
|
|
by acemarke
3150 days ago
|
|
No. The reason why it's written as not just a HOC, but a curried-ish function is so that you could potentially reuse the "connection" definition for multiple components: const SpecificConnection = connect(mapState, mapDispatch);
const ConnectedFirst = SpecificConnection(FirstComponent);
const ConnectedSecond = SpecificConnection(SecondComponent);
Admittedly, I suspect that use case isn't popping up very often. Most of the time what I see is that a given component type is only connected once, and a given connection setup is only used with one component. I also don't remember seeing specific comments by Dan or Andrew saying that's why it's written this way - I'm inferring the intent from the API definition. Still, it's a potentially useful capability in the API, so no reason to throw it away. |
|