Skip to content

Kill .type (was deprecated in 0.13, to be removed in 0.14) #4009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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