|
1 | 1 | import React from 'react'; |
| 2 | +import { pickInObject, omitInObject } from '../../commons/utilities'; |
2 | 3 | import { connect } from 'react-redux'; |
3 | 4 | import { bindActionCreators } from 'redux'; |
4 | 5 | import { createStructuredSelector } from 'reselect'; |
@@ -68,33 +69,57 @@ class Container extends React.Component { |
68 | 69 | } |
69 | 70 |
|
70 | 71 | render () { |
| 72 | + const wrapperPicked = pickInObject( |
| 73 | + this.props, |
| 74 | + ['wrappedComponent', 'wrappedProps', 'stateProps', 'populatedProps', 'children'] |
| 75 | + ); |
| 76 | + const restPicked = omitInObject( |
| 77 | + this.props, |
| 78 | + [ |
| 79 | + 'componentKey', |
| 80 | + 'componentName', |
| 81 | + 'componentInstance', |
| 82 | + 'containerEventHandlers', |
| 83 | + 'containerProperties', |
| 84 | + 'wrappedProps', |
| 85 | + 'populatedProps', |
| 86 | + 'wrappedComponent', |
| 87 | + 'children' |
| 88 | + ] |
| 89 | + ); |
71 | 90 | const { |
72 | 91 | wrappedComponent, |
73 | 92 | wrappedProps, |
74 | 93 | stateProps, |
75 | 94 | populatedProps, |
76 | | - cloneProps, // this props may come from the parent component that wants to clone this instance |
77 | 95 | children |
78 | | - } = this.props; |
| 96 | + } = wrapperPicked; |
79 | 97 | return React.createElement( |
80 | 98 | wrappedComponent, |
81 | | - { ...wrappedProps, ...cloneProps, ...this.wrappedHandlers, ...populatedProps, ...stateProps }, |
| 99 | + { ...restPicked, ...wrappedProps, ...this.wrappedHandlers, ...populatedProps, ...stateProps }, |
82 | 100 | children |
83 | 101 | ); |
84 | 102 | } |
85 | 103 | } |
86 | 104 |
|
87 | 105 | class Component extends React.Component { |
88 | 106 | render () { |
| 107 | + const wrapperPicked = pickInObject( |
| 108 | + this.props, |
| 109 | + ['wrappedComponent', 'wrappedProps', 'children'] |
| 110 | + ); |
| 111 | + const restPicked = omitInObject( |
| 112 | + this.props, |
| 113 | + ['wrappedComponent', 'wrappedProps', 'children'] |
| 114 | + ); |
89 | 115 | const { |
90 | 116 | wrappedComponent, |
91 | 117 | wrappedProps, |
92 | | - cloneProps, // this props may come from the parent component that wants to clone this instance |
93 | 118 | children |
94 | | - } = this.props; |
| 119 | + } = wrapperPicked; |
95 | 120 | return React.createElement( |
96 | 121 | wrappedComponent, |
97 | | - { ...wrappedProps, ...cloneProps }, |
| 122 | + { ...restPicked, ...wrappedProps }, |
98 | 123 | children |
99 | 124 | ); |
100 | 125 | } |
@@ -133,7 +158,6 @@ export default function createContainer ( |
133 | 158 | }); |
134 | 159 |
|
135 | 160 | const wrapperProps = { |
136 | | - key: props.key, |
137 | 161 | componentKey, |
138 | 162 | componentName, |
139 | 163 | componentInstance, |
|
0 commit comments