Skip to content

Commit 9b36b04

Browse files
committed
Drop internal uses of .type on the class
1 parent 199a7d6 commit 9b36b04

File tree

6 files changed

+16
-26
lines changed

6 files changed

+16
-26
lines changed

src/core/ReactNativeComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function createInstanceForTag(tag, props, parentType) {
5858
return new genericComponentClass(tag, props);
5959
}
6060
// Unwrap legacy factories
61-
return new componentClass.type(props);
61+
return new componentClass(props);
6262
}
6363

6464
var ReactNativeComponent = {

src/core/__tests__/ReactCompositeComponent-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,8 @@ describe('ReactCompositeComponent', function() {
12371237
expect(Component.ghi).toBe(null);
12381238
expect(instance.constructor.jkl).toBe('mno');
12391239
expect(Component.jkl).toBe('mno');
1240-
expect(instance.constructor.pqr()).toBe(Component.type);
1241-
expect(Component.pqr()).toBe(Component.type);
1240+
expect(instance.constructor.pqr()).toBe(Component);
1241+
expect(Component.pqr()).toBe(Component);
12421242
});
12431243

12441244
it('should throw if a reserved property is in statics', function() {

src/core/__tests__/ReactCompositeComponentMixin-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,20 @@ describe('ReactCompositeComponent-mixin', function() {
152152
});
153153

154154
it('should validate prop types via mixins', function() {
155-
expect(TestComponent.type.propTypes).toBeDefined();
156-
expect(TestComponent.type.propTypes.value)
155+
expect(TestComponent.propTypes).toBeDefined();
156+
expect(TestComponent.propTypes.value)
157157
.toBe(mixinPropValidator);
158158
});
159159

160160
it('should override mixin prop types with class prop types', function() {
161161
// Sanity check...
162162
expect(componentPropValidator).toNotBe(mixinPropValidator);
163163
// Actually check...
164-
expect(TestComponentWithPropTypes.type.propTypes)
164+
expect(TestComponentWithPropTypes.propTypes)
165165
.toBeDefined();
166-
expect(TestComponentWithPropTypes.type.propTypes.value)
166+
expect(TestComponentWithPropTypes.propTypes.value)
167167
.toNotBe(mixinPropValidator);
168-
expect(TestComponentWithPropTypes.type.propTypes.value)
168+
expect(TestComponentWithPropTypes.propTypes.value)
169169
.toBe(componentPropValidator);
170170
});
171171
});

src/core/__tests__/ReactCompositeComponentSpec-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('ReactCompositeComponent-spec', function() {
4141
}
4242
});
4343

44-
expect(TestComponent.type.displayName)
44+
expect(TestComponent.displayName)
4545
.toBe('TestComponent');
4646
});
4747

@@ -56,8 +56,8 @@ describe('ReactCompositeComponent-spec', function() {
5656
}
5757
});
5858

59-
expect(TestComponent.type.propTypes).toBeDefined();
60-
expect(TestComponent.type.propTypes.value)
59+
expect(TestComponent.propTypes).toBeDefined();
60+
expect(TestComponent.propTypes.value)
6161
.toBe(propValidator);
6262
});
6363
});

src/core/__tests__/ReactElement-test.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('ReactElement', function() {
2626
ComponentFactory = React.createClass({
2727
render: function() { return <div />; }
2828
});
29-
ComponentClass = ComponentFactory.type;
29+
ComponentClass = ComponentFactory;
3030
});
3131

3232
it('returns a complete element according to spec', function() {
@@ -338,13 +338,6 @@ describe('ReactElement', function() {
338338
expect(ReactElement.isValidElement(Component)).toEqual(false);
339339
});
340340

341-
it('should expose the underlying class from a legacy factory', function() {
342-
var Legacy = React.createClass({ render: function() { } });
343-
var factory = React.createFactory(Legacy);
344-
expect(factory.type).toBe(Legacy.type);
345-
expect(factory().type).toBe(Legacy.type);
346-
});
347-
348341
it('allows the use of PropTypes validators in statics', function() {
349342
var Component = React.createClass({
350343
render: () => null,

src/test/reactComponentExpect.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,9 @@ assign(reactComponentExpect.prototype, {
9797

9898
// Matchers ------------------------------------------------------------------
9999

100-
toBeComponentOfType: function(convenienceConstructor) {
101-
var type = typeof convenienceConstructor === 'string' ?
102-
convenienceConstructor :
103-
convenienceConstructor.type;
100+
toBeComponentOfType: function(constructor) {
104101
expect(
105-
this.instance()._currentElement.type === type
102+
this.instance()._currentElement.type === constructor
106103
).toBe(true);
107104
return this;
108105
},
@@ -119,10 +116,10 @@ assign(reactComponentExpect.prototype, {
119116
return this;
120117
},
121118

122-
toBeCompositeComponentWithType: function(convenienceConstructor) {
119+
toBeCompositeComponentWithType: function(constructor) {
123120
this.toBeCompositeComponent();
124121
expect(
125-
this.instance()._currentElement.type === convenienceConstructor.type
122+
this.instance()._currentElement.type === constructor
126123
).toBe(true);
127124
return this;
128125
},

0 commit comments

Comments
 (0)