@samitouri / QOS-React-2 / commits / accd0d874d

Removed cloneWithProps addon.

jim committed Jan 15, 2016 at 14:10 UTC accd0d874dc82990ec248f0dd74e943f3f4be270
4 files changed -266
grunt/tasks/npm-react-addons.js
-5
@@ -36,11 +36,6 @@ var addons = {
36 name: 'transition-group',
37 docs: 'animation',
38 },
39 - cloneWithProps: {
40 - module: 'cloneWithProps',
41 - name: 'clone-with-props',
42 - docs: 'clone-with-props',
43 - },
39 createFragment: {
40 module: 'ReactFragment',
41 method: 'create',
src/addons/ReactWithAddons.js
-2
@@ -27,7 +27,6 @@ var ReactFragment = require('ReactFragment');
27 var ReactTransitionGroup = require('ReactTransitionGroup');
28 var ReactUpdates = require('ReactUpdates');
29
30 -var cloneWithProps = require('cloneWithProps');
30 var shallowCompare = require('shallowCompare');
31 var update = require('update');
32 var warning = require('warning');
@@ -51,7 +50,6 @@ React.addons = {
50 }
51 return ReactUpdates.batchedUpdates.apply(this, arguments);
52 },
54 - cloneWithProps: cloneWithProps,
53 createFragment: ReactFragment.create,
54 shallowCompare: shallowCompare,
55 update: update,
src/isomorphic/deprecated/__tests__/cloneWithProps-test.js deleted
-196
@@ -1,196 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @emails react-core
10 - */
11 -
12 -'use strict';
13 -
14 -var React;
15 -var ReactDOM;
16 -var ReactTestUtils;
17 -
18 -var onlyChild;
19 -var cloneWithProps;
20 -var emptyObject;
21 -
22 -describe('cloneWithProps', function() {
23 -
24 - beforeEach(function() {
25 - jest.resetModuleRegistry();
26 - React = require('React');
27 - ReactDOM = require('ReactDOM');
28 - ReactTestUtils = require('ReactTestUtils');
29 - onlyChild = require('onlyChild');
30 - cloneWithProps = require('cloneWithProps');
31 - emptyObject = require('emptyObject');
32 - spyOn(console, 'error');
33 - });
34 -
35 - it('should warn once because it is deprecated', function() {
36 - var Parent = React.createClass({
37 - render: function() {
38 - return (
39 - <div>
40 - {cloneWithProps(onlyChild(this.props.children), {})}
41 - </div>
42 - );
43 - },
44 - });
45 - ReactTestUtils.renderIntoDocument(<Parent><div /></Parent>);
46 - ReactTestUtils.renderIntoDocument(<Parent><div /></Parent>);
47 - expect(console.error.argsForCall.length).toBe(1);
48 - expect(console.error.argsForCall[0][0]).toContain(
49 - 'cloneWithProps(...) is deprecated. ' +
50 - 'Please use React.cloneElement instead.'
51 - );
52 - });
53 -
54 - it('should clone a DOM component with new props', function() {
55 - var Grandparent = React.createClass({
56 - render: function() {
57 - return <Parent><div className="child" /></Parent>;
58 - },
59 - });
60 - var Parent = React.createClass({
61 - render: function() {
62 - return (
63 - <div className="parent">
64 - {cloneWithProps(onlyChild(this.props.children), {className: 'xyz'})}
65 - </div>
66 - );
67 - },
68 - });
69 - var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
70 - expect(ReactDOM.findDOMNode(component).childNodes[0].className)
71 - .toBe('xyz child');
72 - });
73 -
74 - it('should clone a composite component with new props', function() {
75 -
76 - var Child = React.createClass({
77 - render: function() {
78 - return <div className={this.props.className} />;
79 - },
80 - });
81 -
82 - var Grandparent = React.createClass({
83 - render: function() {
84 - return <Parent><Child className="child" /></Parent>;
85 - },
86 - });
87 - var Parent = React.createClass({
88 - render: function() {
89 - return (
90 - <div className="parent">
91 - {cloneWithProps(onlyChild(this.props.children), {className: 'xyz'})}
92 - </div>
93 - );
94 - },
95 - });
96 - var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
97 - expect(ReactDOM.findDOMNode(component).childNodes[0].className)
98 - .toBe('xyz child');
99 - });
100 -
101 - it('should warn when cloning with refs', function() {
102 - var Grandparent = React.createClass({
103 - render: function() {
104 - return <Parent><div ref="yolo" /></Parent>;
105 - },
106 - });
107 - var Parent = React.createClass({
108 - render: function() {
109 - return (
110 - <div>
111 - {cloneWithProps(onlyChild(this.props.children), {className: 'xyz'})}
112 - </div>
113 - );
114 - },
115 - });
116 -
117 - var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
118 - expect(component.refs).toBe(emptyObject);
119 - expect(console.error.argsForCall.length).toBe(2);
120 - });
121 -
122 - it('should transfer the key property', function() {
123 - var Component = React.createClass({
124 - render: function() {
125 - return null;
126 - },
127 - });
128 - var clone = cloneWithProps(<Component />, {key: 'xyz'});
129 - expect(clone.key).toBe('xyz');
130 - });
131 -
132 - it('should transfer children', function() {
133 - var Component = React.createClass({
134 - render: function() {
135 - expect(this.props.children).toBe('xyz');
136 - return <div />;
137 - },
138 - });
139 -
140 - ReactTestUtils.renderIntoDocument(
141 - cloneWithProps(<Component />, {children: 'xyz'})
142 - );
143 - });
144 -
145 - it('should shallow clone children', function() {
146 - var Component = React.createClass({
147 - render: function() {
148 - expect(this.props.children).toBe('xyz');
149 - return <div />;
150 - },
151 - });
152 -
153 - ReactTestUtils.renderIntoDocument(
154 - cloneWithProps(<Component>xyz</Component>, {})
155 - );
156 - });
157 -
158 - it('should support keys and refs', function() {
159 - var Component = React.createClass({
160 - render: function() {
161 - return <div />;
162 - },
163 - });
164 -
165 - var Parent = React.createClass({
166 - render: function() {
167 - var clone =
168 - cloneWithProps(this.props.children, {key: 'xyz', ref: 'xyz'});
169 - expect(clone.key).toBe('xyz');
170 - expect(clone.ref).toBe('xyz');
171 - return <div>{clone}</div>;
172 - },
173 - });
174 -
175 - var Grandparent = React.createClass({
176 - render: function() {
177 - return <Parent><Component key="abc" /></Parent>;
178 - },
179 - });
180 -
181 - ReactTestUtils.renderIntoDocument(<Grandparent />);
182 - });
183 -
184 - it('should overwrite props', function() {
185 - var Component = React.createClass({
186 - render: function() {
187 - expect(this.props.myprop).toBe('xyz');
188 - return <div />;
189 - },
190 - });
191 -
192 - ReactTestUtils.renderIntoDocument(
193 - cloneWithProps(<Component myprop="abc" />, {myprop: 'xyz'})
194 - );
195 - });
196 -});
src/isomorphic/deprecated/cloneWithProps.js deleted
-63
@@ -1,63 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule cloneWithProps
10 - */
11 -
12 -'use strict';
13 -
14 -var ReactElement = require('ReactElement');
15 -var ReactPropTransferer = require('ReactPropTransferer');
16 -
17 -var keyOf = require('keyOf');
18 -var warning = require('warning');
19 -
20 -var CHILDREN_PROP = keyOf({children: null});
21 -
22 -var didDeprecatedWarn = false;
23 -
24 -/**
25 - * Sometimes you want to change the props of a child passed to you. Usually
26 - * this is to add a CSS class.
27 - *
28 - * @param {ReactElement} child child element you'd like to clone
29 - * @param {object} props props you'd like to modify. className and style will be
30 - * merged automatically.
31 - * @return {ReactElement} a clone of child with props merged in.
32 - * @deprecated
33 - */
34 -function cloneWithProps(child, props) {
35 - if (__DEV__) {
36 - warning(
37 - didDeprecatedWarn,
38 - 'cloneWithProps(...) is deprecated. ' +
39 - 'Please use React.cloneElement instead.'
40 - );
41 - didDeprecatedWarn = true;
42 - warning(
43 - !child.ref,
44 - 'You are calling cloneWithProps() on a child with a ref. This is ' +
45 - 'dangerous because you\'re creating a new child which will not be ' +
46 - 'added as a ref to its parent.'
47 - );
48 - }
49 -
50 - var newProps = ReactPropTransferer.mergeProps(props, child.props);
51 -
52 - // Use `child.props.children` if it is provided.
53 - if (!newProps.hasOwnProperty(CHILDREN_PROP) &&
54 - child.props.hasOwnProperty(CHILDREN_PROP)) {
55 - newProps.children = child.props.children;
56 - }
57 -
58 - // The current API doesn't retain _owner, which is why this
59 - // doesn't use ReactElement.cloneAndReplaceProps.
60 - return ReactElement.createElement(child.type, newProps);
61 -}
62 -
63 -module.exports = cloneWithProps;