Skip to content
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
4 changes: 0 additions & 4 deletions src/browser/__tests__/ReactDOM-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ describe('ReactDOM', function() {
expect(dog.className).toBe('bigdog');
});

it('should be a valid class', function() {
expect(React.isValidClass(ReactDOM.div)).toBe(false);
});

it('allow React.DOM factories to be called without warnings', function() {
spyOn(console, 'warn');
var element = React.DOM.div();
Expand Down
2 changes: 1 addition & 1 deletion src/browser/ui/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var React = {
renderToString: ReactServerRendering.renderToString,
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
isValidClass: ReactLegacyElement.isValidFactory,
isValidClass: ReactLegacyElement.isValidClass,
isValidElement: ReactElement.isValidElement,
withContext: ReactContext.withContext,

Expand Down
11 changes: 11 additions & 0 deletions src/core/ReactLegacyElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ ReactLegacyElementFactory.isValidFactory = function(factory) {
factory.isReactLegacyFactory === LEGACY_MARKER;
};

ReactLegacyElementFactory.isValidClass = function(factory) {
if (__DEV__) {
warning(
false,
'isValidClass is deprecated and will be removed in a future release. ' +
'Use a more specific validator instead.'
);
}
return ReactLegacyElementFactory.isValidFactory(factory);
};

ReactLegacyElementFactory._isLegacyCallWarningEnabled = true;

module.exports = ReactLegacyElementFactory;
22 changes: 20 additions & 2 deletions src/core/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -878,17 +878,28 @@ describe('ReactCompositeComponent', function() {
expect(ReactMount.purgeID.callCount).toBe(4);
});

it('should detect valid CompositeComponent classes', function() {
it('should warn but detect valid CompositeComponent classes', function() {
var warn = console.warn;
console.warn = mocks.getMockFunction();

var Component = React.createClass({
render: function() {
return <div/>;
}
});

expect(React.isValidClass(Component)).toBe(true);

expect(console.warn.mock.calls.length).toBe(1);
expect(console.warn.mock.calls[0][0]).toContain(
'isValidClass is deprecated and will be removed in a future release'
);
});

it('should detect invalid CompositeComponent classes', function() {
it('should warn but detect invalid CompositeComponent classes', function() {
var warn = console.warn;
console.warn = mocks.getMockFunction();

var FnComponent = function() {
return false;
};
Expand All @@ -903,6 +914,13 @@ describe('ReactCompositeComponent', function() {
expect(React.isValidClass(FnComponent)).toBe(false);
expect(React.isValidClass(NullComponent)).toBe(false);
expect(React.isValidClass(TrickFnComponent)).toBe(false);

expect(console.warn.mock.calls.length).toBe(3);
console.warn.mock.calls.forEach(function(call) {
expect(call[0]).toContain(
'isValidClass is deprecated and will be removed in a future release'
);
});
});

it('should warn when shouldComponentUpdate() returns undefined', function() {
Expand Down