Skip to content

Commit 0cf72c8

Browse files
committed
Merge pull request react-bootstrap#277 from jquense/clone-with-props
Future proof cloneWithProps a little. Remove unused internal utils
2 parents 9751f49 + 726c730 commit 0cf72c8

3 files changed

Lines changed: 9 additions & 99 deletions

File tree

src/utils/ReactContext.js

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/utils/ReactCurrentOwner.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/utils/cloneWithProps.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,17 @@ function cloneWithProps(child, props) {
127127
newProps.children = child.props.children;
128128
}
129129

130+
if (React.version.substr(0, 4) === '0.12'){
131+
var mockLegacyFactory = function(){};
132+
mockLegacyFactory.isReactLegacyFactory = true;
133+
mockLegacyFactory.type = child.type;
134+
135+
return React.createElement(mockLegacyFactory, newProps);
136+
}
137+
130138
// The current API doesn't retain _owner and _context, which is why this
131139
// doesn't use ReactElement.cloneAndReplaceProps.
132-
var mockLegacyFactory = function(){};
133-
mockLegacyFactory.isReactLegacyFactory = true;
134-
mockLegacyFactory.type = child.type;
135-
return React.createElement(mockLegacyFactory, newProps);
140+
return React.createElement(child.type, newProps);
136141
}
137142

138143
module.exports = cloneWithProps;

0 commit comments

Comments
 (0)