Amiramix Amiramix - 1 year ago 114
React JSX Question

Is paramemterless connect valid?

I sometimes see the following in our code:

@connect(() => ({}))
export default class SomeClass extends Componet {

I would understand if
was taking any arguments, e.g.
, but does it have any purpose when it's parameter-less?

Answer Source

It Injects to component just dispatch function. You can access dispatch in component through this.props.dispatch.

Api docs‌​les

if you don't map any slice of state to props, you should use connect(), otherwise it doesnt make any sense. Connected component will be notified , and it will invoke checking shalow equality of new stateProps and previous stateProps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download