Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/core/ReactCompositeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ var ReactCompositeComponentMixin = {
for (propName in propTypes) {
var checkProp = propTypes[propName];
if (checkProp) {
checkProp(props, propName, componentName);
checkProp.call(this, props, propName, componentName);
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions src/core/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,30 @@ describe('ReactCompositeComponent', function() {
}).not.toThrow();
});

it('should allow custom propTypes to use mixins', function(){
var Mixin = {
keyValidation: function(){
throw new Error('Validation failed!');
}
}

var Component = React.createClass({
mixins: [Mixin],
propTypes: {
key: function(){
this.keyValidation();
}
},
render: function() {
return <span></span>;
}
});

expect(function() {
ReactTestUtils.renderIntoDocument(<Component />);
}).toThrow('Validation failed!');
});

it('should not allow `forceUpdate` on unmounted components', function() {
var container = document.createElement('div');
document.documentElement.appendChild(container);
Expand Down