mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Deprecate transferPropsTo
This commit is contained in:
committed by
Paul O’Shannessy
parent
de711efcc9
commit
3a7dbe6b73
@@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user