Deprecate transferPropsTo

This commit is contained in:
Sebastian Markbage
2014-07-18 22:01:36 -07:00
committed by Paul O’Shannessy
parent de711efcc9
commit 3a7dbe6b73
2 changed files with 22 additions and 1 deletions
+14
View File
@@ -22,6 +22,9 @@ var emptyFunction = require('emptyFunction');
var invariant = require('invariant');
var joinClasses = require('joinClasses');
var merge = require('merge');
var warning = require('warning');
var didWarn = false;
/**
* Creates a transfer strategy that will merge prop values using the supplied
@@ -141,6 +144,17 @@ var ReactPropTransferer = {
descriptor.type.displayName
);
if (__DEV__) {
if (!didWarn) {
didWarn = true;
warning(
false,
'transferPropsTo is deprecated. ' +
'See http://fb.me/react-transferpropsto for more information.'
);
}
}
// Because descriptors are immutable we have to merge into the existing
// props object rather than clone it.
transferInto(descriptor.props, this.props);
@@ -28,13 +28,18 @@ var TestComponent;
describe('ReactPropTransferer', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
React = require('React');
ReactTestUtils = require('ReactTestUtils');
reactComponentExpect = require('reactComponentExpect');
// We expect to get a warning from transferPropsTo since it's deprecated
spyOn(console, 'warn');
TestComponent = React.createClass({
render: function() {
return this.transferPropsTo(
var result = this.transferPropsTo(
<input
className="textinput"
style={{display: 'block', color: 'green'}}
@@ -42,6 +47,8 @@ describe('ReactPropTransferer', function() {
value=""
/>
);
expect(console.warn).toHaveBeenCalled();
return result;
}
});
});