Skip to content

Commit 98bf0f0

Browse files
committed
Use invariant to conditionally throws the error
1 parent 527497f commit 98bf0f0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/createConnector.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import identity from 'lodash/utility/identity';
22
import shallowEqual from '../utils/shallowEqual';
33
import isPlainObject from 'lodash/lang/isPlainObject';
4+
import invariant from 'invariant';
45

56
export default function createConnector(React) {
67
const { Component, PropTypes } = React;
@@ -61,9 +62,11 @@ export default function createConnector(React) {
6162
const state = context.redux.getState();
6263
const slice = props.select(state);
6364

64-
if (!isPlainObject(slice)) {
65-
throw new Error('prop `select` should always return an object');
66-
}
65+
invariant(
66+
isPlainObject(slice),
67+
'The return value of `select` prop must be an object. Instead received %s.',
68+
slice
69+
);
6770

6871
return { slice };
6972
}

0 commit comments

Comments
 (0)