Kill .type (was deprecated in 0.13, to be removed in 0.14)
Jim committed
Jun 2, 2015 at 13:36 UTC
c9153e6462622cd58ada0c1900e888513c99da5c
2 files changed
-56
src/isomorphic/classic/class/ReactClass.js
-27
@@ -704,23 +704,6 @@ function bindAutoBindMethods(component) {
704
}
705
}
706
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
-
707
/**
708
* Add more to the ReactClass base class. These are all legacy features and
709
* therefore not already part of the modern ReactComponent.
@@ -915,16 +898,6 @@ var ReactClass = {
898
}
899
}
900
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
-
901
return Constructor;
902
},
903
src/isomorphic/classic/class/__tests__/ReactClass-test.js
-29
@@ -44,35 +44,6 @@ describe('ReactClass-spec', function() {
44
.toBe('TestComponent');
45
});
46
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
-
47
it('should copy prop types onto the Constructor', function() {
48
var propValidator = mocks.getMockFunction();
49
var TestComponent = React.createClass({