Skip to content

Commit

Permalink
Merge pull request #4009 from jimfb/kill-.type
Browse files Browse the repository at this point in the history
Kill .type (was deprecated in 0.13, to be removed in 0.14)
  • Loading branch information
jimfb committed Jun 2, 2015
2 parents 0e37fde + c9153e6 commit e0e8270
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
27 changes: 0 additions & 27 deletions src/isomorphic/classic/class/ReactClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,23 +704,6 @@ function bindAutoBindMethods(component) {
}
}

var typeDeprecationDescriptor = {
enumerable: false,
get: function() {
var displayName = this.displayName || this.name || 'Component';
warning(
false,
'%s.type is deprecated. Use %s directly to access the class.',
displayName,
displayName
);
Object.defineProperty(this, 'type', {
value: this
});
return this;
}
};

/**
* Add more to the ReactClass base class. These are all legacy features and
* therefore not already part of the modern ReactComponent.
Expand Down Expand Up @@ -915,16 +898,6 @@ var ReactClass = {
}
}

// Legacy hook
Constructor.type = Constructor;
if (__DEV__) {
try {
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
} catch (x) {
// IE will fail on defineProperty (es5-shim/sham too)
}
}

return Constructor;
},

Expand Down
29 changes: 0 additions & 29 deletions src/isomorphic/classic/class/__tests__/ReactClass-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,6 @@ describe('ReactClass-spec', function() {
.toBe('TestComponent');
});

it('should warn when accessing .type on a React class', function() {
var TestComponent = React.createClass({
render: function() {
return <div />;
}
});
var SecondTestComponent = React.createClass({
render: function() {
return <div />;
}
});
expect(TestComponent.type).toBe(TestComponent);
expect(console.error.argsForCall.length).toBe(1);
expect(console.error.argsForCall[0][0]).toBe(
'Warning: TestComponent.type is deprecated. Use TestComponent ' +
'directly to access the class.'
);
// Warn once per class
expect(SecondTestComponent.type).toBe(SecondTestComponent);
expect(console.error.argsForCall.length).toBe(2);
expect(console.error.argsForCall[1][0]).toBe(
'Warning: SecondTestComponent.type is deprecated. Use ' +
'SecondTestComponent directly to access the class.'
);
// Not again
expect(TestComponent.type).toBe(TestComponent);
expect(console.error.argsForCall.length).toBe(2);
});

it('should copy prop types onto the Constructor', function() {
var propValidator = mocks.getMockFunction();
var TestComponent = React.createClass({
Expand Down

0 comments on commit e0e8270

Please sign in to comment.