Open mariosanchez opened 5 years ago
It's a nice idea. If it were possible, I'd would prefer to have a function with two arities instead of passing a null though.
The main point of this would be to not execute the mapStateToProps
if the component does not need to be subscribed to the state. But I can't imagine how to check this without executing the function and checking its returned values. With null
will be easier to check it.
Anyway, I'd prefer to use null
instead of () => {}
. :stuck_out_tongue:
In some edge cases we are using
subscribe
function only to inject props, yet not for subscribing it to the state. In those cases we aren't passing by mapStateToProps.Despite we consider it an anti-pattern, because we could simply compose the component in order to achieve that, it will be a improvement to not execute all the subscription flow if no
mapStateToProps
is passed by in thesubscribe
function.Now we are passing by an empty fucntion:
This should allow to do this: