Skip to content

Commit 402b46f

Browse files
committed
Slightly simplify the code
1 parent 7831b92 commit 402b46f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/components/createConnect.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({
1111
...stateProps,
1212
...dispatchProps
1313
});
14-
const defaultOptions = {
15-
pure: true
16-
};
1714

1815
function getDisplayName(Component) {
1916
return Component.displayName || Component.name || 'Component';
@@ -26,7 +23,7 @@ export default function createConnect(React) {
2623
const { Component, PropTypes } = React;
2724
const storeShape = createStoreShape(PropTypes);
2825

29-
return function connect(mapStateToProps, mapDispatchToProps, mergeProps, options) {
26+
return function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) {
3027
const shouldSubscribe = Boolean(mapStateToProps);
3128
const finalMapStateToProps = mapStateToProps || defaultMapStateToProps;
3229
const finalMapDispatchToProps = isPlainObject(mapDispatchToProps) ?
@@ -35,7 +32,7 @@ export default function createConnect(React) {
3532
const finalMergeProps = mergeProps || defaultMergeProps;
3633
const shouldUpdateStateProps = finalMapStateToProps.length > 1;
3734
const shouldUpdateDispatchProps = finalMapDispatchToProps.length > 1;
38-
const finalOptions = {...defaultOptions, ...options} || defaultOptions;
35+
const { pure = true } = options;
3936

4037
// Helps track hot reloading.
4138
const version = nextVersion++;
@@ -92,7 +89,7 @@ export default function createConnect(React) {
9289
};
9390

9491
shouldComponentUpdate(nextProps, nextState) {
95-
return !finalOptions.pure || !shallowEqual(this.state.props, nextState.props);
92+
return !pure || !shallowEqual(this.state.props, nextState.props);
9693
}
9794

9895
constructor(props, context) {

0 commit comments

Comments
 (0)