@samitouri / QOS-React-2 / commits / 3a7dbe6b73

Deprecate transferPropsTo

Sebastian Markbage committed Jul 18, 2014 at 10:04 UTC 3a7dbe6b737cc0b15065faae445503d46916826a
2 files changed +22 -1
src/core/ReactPropTransferer.js
+14
@@ -22,6 +22,9 @@ var emptyFunction = require('emptyFunction');
22 var invariant = require('invariant');
23 var joinClasses = require('joinClasses');
24 var merge = require('merge');
25 +var warning = require('warning');
26 +
27 +var didWarn = false;
28
29 /**
30 * Creates a transfer strategy that will merge prop values using the supplied
@@ -141,6 +144,17 @@ var ReactPropTransferer = {
144 descriptor.type.displayName
145 );
146
147 + if (__DEV__) {
148 + if (!didWarn) {
149 + didWarn = true;
150 + warning(
151 + false,
152 + 'transferPropsTo is deprecated. ' +
153 + 'See http://fb.me/react-transferpropsto for more information.'
154 + );
155 + }
156 + }
157 +
158 // Because descriptors are immutable we have to merge into the existing
159 // props object rather than clone it.
160 transferInto(descriptor.props, this.props);
src/core/__tests__/ReactPropTransferer-test.js
+8 -1
@@ -28,13 +28,18 @@ var TestComponent;
28 describe('ReactPropTransferer', function() {
29
30 beforeEach(function() {
31 + require('mock-modules').dumpCache();
32 +
33 React = require('React');
34 ReactTestUtils = require('ReactTestUtils');
35 reactComponentExpect = require('reactComponentExpect');
36
37 + // We expect to get a warning from transferPropsTo since it's deprecated
38 + spyOn(console, 'warn');
39 +
40 TestComponent = React.createClass({
41 render: function() {
37 - return this.transferPropsTo(
42 + var result = this.transferPropsTo(
43 <input
44 className="textinput"
45 style={{display: 'block', color: 'green'}}
@@ -42,6 +47,8 @@ describe('ReactPropTransferer', function() {
47 value=""
48 />
49 );
50 + expect(console.warn).toHaveBeenCalled();
51 + return result;
52 }
53 });
54 });