Skip to content

Commit 61a3df7

Browse files
committed
Style tweaks
1 parent e14533e commit 61a3df7

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/components/createConnect.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({
1212
...dispatchProps
1313
});
1414

15+
const resetValue = (_, key) => ({ [key]: undefined });
16+
1517
function getDisplayName(Component) {
1618
return Component.displayName || Component.name || 'Component';
1719
}
@@ -132,11 +134,8 @@ export default function createConnect(React) {
132134
const nextState = this.computeNextState(props);
133135
if (!shallowEqual(nextState, this.state)) {
134136
this.setState({
135-
...Object.keys(this.state)
136-
.reduce((r, k) => ({
137-
[k]: undefined
138-
}), {}),
139-
...nextState,
137+
...Object.keys(this.state).reduce(resetValue, {}),
138+
...nextState
140139
});
141140
}
142141
}

test/components/connect.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ describe('React', () => {
182182

183183
it('should remove undefined props', () => {
184184
const store = createStore(() => ({}));
185-
let props = {x: true};
185+
let props = { x: true };
186186
let container;
187187

188-
@connect(()=>({}), ()=>({}))
188+
@connect(() => ({}), () => ({}))
189189
class ConnectContainer extends Component {
190190
render() {
191191
return (

0 commit comments

Comments
 (0)