Skip to content

Commit e0e8270

Browse files
committed
Merge pull request #4009 from jimfb/kill-.type
Kill .type (was deprecated in 0.13, to be removed in 0.14)
2 parents 0e37fde + c9153e6 commit e0e8270

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

src/isomorphic/classic/class/ReactClass.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -704,23 +704,6 @@ function bindAutoBindMethods(component) {
704704
}
705705
}
706706

707-
var typeDeprecationDescriptor = {
708-
enumerable: false,
709-
get: function() {
710-
var displayName = this.displayName || this.name || 'Component';
711-
warning(
712-
false,
713-
'%s.type is deprecated. Use %s directly to access the class.',
714-
displayName,
715-
displayName
716-
);
717-
Object.defineProperty(this, 'type', {
718-
value: this
719-
});
720-
return this;
721-
}
722-
};
723-
724707
/**
725708
* Add more to the ReactClass base class. These are all legacy features and
726709
* therefore not already part of the modern ReactComponent.
@@ -915,16 +898,6 @@ var ReactClass = {
915898
}
916899
}
917900

918-
// Legacy hook
919-
Constructor.type = Constructor;
920-
if (__DEV__) {
921-
try {
922-
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
923-
} catch (x) {
924-
// IE will fail on defineProperty (es5-shim/sham too)
925-
}
926-
}
927-
928901
return Constructor;
929902
},
930903

src/isomorphic/classic/class/__tests__/ReactClass-test.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,6 @@ describe('ReactClass-spec', function() {
4444
.toBe('TestComponent');
4545
});
4646

47-
it('should warn when accessing .type on a React class', function() {
48-
var TestComponent = React.createClass({
49-
render: function() {
50-
return <div />;
51-
}
52-
});
53-
var SecondTestComponent = React.createClass({
54-
render: function() {
55-
return <div />;
56-
}
57-
});
58-
expect(TestComponent.type).toBe(TestComponent);
59-
expect(console.error.argsForCall.length).toBe(1);
60-
expect(console.error.argsForCall[0][0]).toBe(
61-
'Warning: TestComponent.type is deprecated. Use TestComponent ' +
62-
'directly to access the class.'
63-
);
64-
// Warn once per class
65-
expect(SecondTestComponent.type).toBe(SecondTestComponent);
66-
expect(console.error.argsForCall.length).toBe(2);
67-
expect(console.error.argsForCall[1][0]).toBe(
68-
'Warning: SecondTestComponent.type is deprecated. Use ' +
69-
'SecondTestComponent directly to access the class.'
70-
);
71-
// Not again
72-
expect(TestComponent.type).toBe(TestComponent);
73-
expect(console.error.argsForCall.length).toBe(2);
74-
});
75-
7647
it('should copy prop types onto the Constructor', function() {
7748
var propValidator = mocks.getMockFunction();
7849
var TestComponent = React.createClass({

0 commit comments

Comments
 (0)