Skip to content

Commit ca47a0a

Browse files
committed
Dispatch should be passed by default
1 parent 47a7df7 commit ca47a0a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/components/createConnect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import wrapActionCreators from '../utils/wrapActionCreators';
66
import invariant from 'invariant';
77

88
const emptySelector = () => ({});
9-
const emptyBinder = () => ({});
9+
const defaultBinder = dispatch => ({ dispatch });
1010
const identityMerge = (slice, actionsCreators, props) => ({
1111
...props,
1212
...slice,
@@ -23,7 +23,7 @@ export default function createConnect(React) {
2323

2424
return function connect(
2525
select,
26-
dispatchBinder = emptyBinder,
26+
dispatchBinder = defaultBinder,
2727
mergeHandler = identityMerge
2828
) {
2929
const shouldSubscribe = select ? true : false;

test/components/connect.spec.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('React', () => {
5353
expect(container.context.store).toBe(store);
5454
});
5555

56-
it('should pass the state and the props given component', () => {
56+
it('should pass state and props to the given component', () => {
5757
const store = createStore(() => ({
5858
foo: 'bar',
5959
baz: 42,
@@ -244,15 +244,12 @@ describe('React', () => {
244244
expect(decorated.subscribed).toBe(true);
245245
});
246246

247-
it('should not subscribe to stores if select argument is null', () => {
247+
it('should not subscribe to stores if select argument is falsy', () => {
248248
const store = createStore(() => ({
249249
foo: 'bar'
250250
}));
251251

252-
@connect(
253-
null,
254-
dispatch => ({ dispatch })
255-
)
252+
@connect()
256253
class Container extends Component {
257254
render() {
258255
return <div {...this.props} />;

0 commit comments

Comments
 (0)