Skip to content

Commit 4e8b313

Browse files
authored
Revert "warn on duplicate props" (#511)
1 parent 3583e33 commit 4e8b313

File tree

2 files changed

+1
-43
lines changed

2 files changed

+1
-43
lines changed

src/connect/mergeProps.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
import verifyPlainObject from '../utils/verifyPlainObject'
2-
import warning from '../utils/warning'
32

43
export function defaultMergeProps(stateProps, dispatchProps, ownProps) {
5-
if (process.env.NODE_ENV !== 'production') {
6-
const stateKeys = Object.keys(stateProps)
7-
8-
for ( let key of stateKeys ) {
9-
if (typeof ownProps[key] !== 'undefined') {
10-
warning(false, `Duplicate key ${key} sent from both parent and state`)
11-
break
12-
}
13-
}
14-
}
15-
16-
return {
17-
...ownProps,
18-
...stateProps,
19-
...dispatchProps
20-
}
4+
return { ...ownProps, ...stateProps, ...dispatchProps }
215
}
226

237
export function wrapMergePropsFunc(mergeProps) {

test/components/connect.spec.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,32 +79,6 @@ describe('React', () => {
7979
expect(container.context.store).toBe(store)
8080
})
8181

82-
83-
it('should warn if same key is used in state and props', () => {
84-
const store = createStore(() => ({
85-
abc: 'bar'
86-
}))
87-
88-
@connect(({ abc }) => ({ abc }))
89-
class Container extends Component {
90-
render() {
91-
return <Passthrough {...this.props} />
92-
}
93-
}
94-
95-
const errorSpy = expect.spyOn(console, 'error')
96-
97-
TestUtils.renderIntoDocument(
98-
<ProviderMock store={store}>
99-
<Container abc="buz" />
100-
</ProviderMock>
101-
)
102-
errorSpy.destroy()
103-
expect(errorSpy).toHaveBeenCalled()
104-
})
105-
106-
107-
10882
it('should pass state and props to the given component', () => {
10983
const store = createStore(() => ({
11084
foo: 'bar',

0 commit comments

Comments
 (0)