@samitouri / QOS-React-2 / commits / ef971014bc

Deprecate isValidClass

Fixes #2374

Sebastian Markbage committed Oct 19, 2014 at 23:55 UTC ef971014bc22bf4cfecb31ce35de38c231c1c41d
4 files changed +32 -7
src/browser/__tests__/ReactDOM-test.js
-4
@@ -108,10 +108,6 @@ describe('ReactDOM', function() {
108 expect(dog.className).toBe('bigdog');
109 });
110
111 - it('should be a valid class', function() {
112 - expect(React.isValidClass(ReactDOM.div)).toBe(false);
113 - });
114 -
111 it('allow React.DOM factories to be called without warnings', function() {
112 spyOn(console, 'warn');
113 var element = React.DOM.div();
src/browser/ui/React.js
+1 -1
@@ -77,7 +77,7 @@ var React = {
77 renderToString: ReactServerRendering.renderToString,
78 renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
79 unmountComponentAtNode: ReactMount.unmountComponentAtNode,
80 - isValidClass: ReactLegacyElement.isValidFactory,
80 + isValidClass: ReactLegacyElement.isValidClass,
81 isValidElement: ReactElement.isValidElement,
82 withContext: ReactContext.withContext,
83
src/core/ReactLegacyElement.js
+11
@@ -227,6 +227,17 @@ ReactLegacyElementFactory.isValidFactory = function(factory) {
227 factory.isReactLegacyFactory === LEGACY_MARKER;
228 };
229
230 +ReactLegacyElementFactory.isValidClass = function(factory) {
231 + if (__DEV__) {
232 + warning(
233 + false,
234 + 'isValidClass is deprecated and will be removed in a future release. ' +
235 + 'Use a more specific validator instead.'
236 + );
237 + }
238 + return ReactLegacyElementFactory.isValidFactory(factory);
239 +};
240 +
241 ReactLegacyElementFactory._isLegacyCallWarningEnabled = true;
242
243 module.exports = ReactLegacyElementFactory;
src/core/__tests__/ReactCompositeComponent-test.js
+20 -2
@@ -878,7 +878,10 @@ describe('ReactCompositeComponent', function() {
878 expect(ReactMount.purgeID.callCount).toBe(4);
879 });
880
881 - it('should detect valid CompositeComponent classes', function() {
881 + it('should warn but detect valid CompositeComponent classes', function() {
882 + var warn = console.warn;
883 + console.warn = mocks.getMockFunction();
884 +
885 var Component = React.createClass({
886 render: function() {
887 return <div/>;
@@ -886,9 +889,17 @@ describe('ReactCompositeComponent', function() {
889 });
890
891 expect(React.isValidClass(Component)).toBe(true);
892 +
893 + expect(console.warn.mock.calls.length).toBe(1);
894 + expect(console.warn.mock.calls[0][0]).toContain(
895 + 'isValidClass is deprecated and will be removed in a future release'
896 + );
897 });
898
891 - it('should detect invalid CompositeComponent classes', function() {
899 + it('should warn but detect invalid CompositeComponent classes', function() {
900 + var warn = console.warn;
901 + console.warn = mocks.getMockFunction();
902 +
903 var FnComponent = function() {
904 return false;
905 };
@@ -903,6 +914,13 @@ describe('ReactCompositeComponent', function() {
914 expect(React.isValidClass(FnComponent)).toBe(false);
915 expect(React.isValidClass(NullComponent)).toBe(false);
916 expect(React.isValidClass(TrickFnComponent)).toBe(false);
917 +
918 + expect(console.warn.mock.calls.length).toBe(3);
919 + console.warn.mock.calls.forEach(function(call) {
920 + expect(call[0]).toContain(
921 + 'isValidClass is deprecated and will be removed in a future release'
922 + );
923 + });
924 });
925
926 it('should warn when shouldComponentUpdate() returns undefined', function() {