From ed00197649833b73e0f9326ad99545c2853ad73e Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Fri, 7 Apr 2017 15:17:15 -0700 Subject: [PATCH] react-create-class -> create-react-class --- package.json | 1 + scripts/fiber/tests-passing.txt | 2 +- src/isomorphic/__tests__/React-test.js | 2 +- ...=> create-react-class-integration-test.js} | 57 ++++++++----------- yarn.lock | 12 ++-- 5 files changed, 32 insertions(+), 42 deletions(-) rename src/isomorphic/classic/class/__tests__/{react-create-class-integration-test.js => create-react-class-integration-test.js} (91%) diff --git a/package.json b/package.json index 80b6c1d734d89..35589b84c6e68 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "coffee-script": "^1.8.0", "core-js": "^2.2.1", "coveralls": "^2.11.6", + "create-react-class": "^15.5.0", "del": "^2.0.2", "derequire": "^2.0.3", "escape-string-regexp": "^1.0.5", diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 7cf4d1ff0bff4..89dc4c89febb1 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -90,7 +90,7 @@ src/isomorphic/classic/__tests__/ReactContextValidator-test.js * should warn (but not error) if getChildContext method is missing * should pass parent context if getChildContext method is missing -src/isomorphic/classic/class/__tests__/react-create-class-integration-test.js +src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js * should throw when `render` is not specified * should copy prop types onto the Constructor * should warn on invalid prop types diff --git a/src/isomorphic/__tests__/React-test.js b/src/isomorphic/__tests__/React-test.js index 4b9c4960abca8..f2ea926dd9a08 100644 --- a/src/isomorphic/__tests__/React-test.js +++ b/src/isomorphic/__tests__/React-test.js @@ -37,7 +37,7 @@ describe('React', () => { expectDev(console.error.calls.argsFor(0)[0]).toContain( 'React.createClass is no longer supported. Use a plain ' + "JavaScript class instead. If you're not yet ready to migrate, " + - 'react-create-class is available on npm as a temporary, ' + + 'create-react-class is available on npm as a temporary, ' + 'drop-in replacement.', ); }); diff --git a/src/isomorphic/classic/class/__tests__/react-create-class-integration-test.js b/src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js similarity index 91% rename from src/isomorphic/classic/class/__tests__/react-create-class-integration-test.js rename to src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js index cbcb1a2a43cfb..3eddc9730524c 100644 --- a/src/isomorphic/classic/class/__tests__/react-create-class-integration-test.js +++ b/src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js @@ -14,15 +14,15 @@ var React; var ReactDOM; var ReactTestUtils; -var ReactCreateClass; +var createReactClass; -describe('react-create-class-integration', () => { +describe('create-react-class-integration', () => { beforeEach(() => { React = require('React'); ReactDOM = require('ReactDOM'); ReactTestUtils = require('ReactTestUtils'); - var ReactCreateClassFactory = require('react-create-class/factory'); - ReactCreateClass = ReactCreateClassFactory( + var createReactClassFactory = require('create-react-class/factory'); + createReactClass = createReactClassFactory( React.Component, React.isValidElement, require('ReactNoopUpdateQueue'), @@ -31,26 +31,15 @@ describe('react-create-class-integration', () => { it('should throw when `render` is not specified', () => { expect(function() { - ReactCreateClass({}); + createReactClass({}); }).toThrowError( 'createClass(...): Class specification must implement a `render` method.', ); }); - // TODO: Update babel-plugin-transform-react-display-name - xit('should copy `displayName` onto the Constructor', () => { - var TestComponent = ReactCreateClass({ - render: function() { - return
; - }, - }); - - expect(TestComponent.displayName).toBe('TestComponent'); - }); - it('should copy prop types onto the Constructor', () => { var propValidator = jest.fn(); - var TestComponent = ReactCreateClass({ + var TestComponent = createReactClass({ propTypes: { value: propValidator, }, @@ -65,7 +54,7 @@ describe('react-create-class-integration', () => { it('should warn on invalid prop types', () => { spyOn(console, 'error'); - ReactCreateClass({ + createReactClass({ displayName: 'Component', propTypes: { prop: null, @@ -83,7 +72,7 @@ describe('react-create-class-integration', () => { it('should warn on invalid context types', () => { spyOn(console, 'error'); - ReactCreateClass({ + createReactClass({ displayName: 'Component', contextTypes: { prop: null, @@ -101,7 +90,7 @@ describe('react-create-class-integration', () => { it('should throw on invalid child context types', () => { spyOn(console, 'error'); - ReactCreateClass({ + createReactClass({ displayName: 'Component', childContextTypes: { prop: null, @@ -120,7 +109,7 @@ describe('react-create-class-integration', () => { it('should warn when mispelling shouldComponentUpdate', () => { spyOn(console, 'error'); - ReactCreateClass({ + createReactClass({ componentShouldUpdate: function() { return false; }, @@ -135,7 +124,7 @@ describe('react-create-class-integration', () => { 'because the function is expected to return a value.', ); - ReactCreateClass({ + createReactClass({ displayName: 'NamedComponent', componentShouldUpdate: function() { return false; @@ -154,7 +143,7 @@ describe('react-create-class-integration', () => { it('should warn when mispelling componentWillReceiveProps', () => { spyOn(console, 'error'); - ReactCreateClass({ + createReactClass({ componentWillRecieveProps: function() { return false; }, @@ -171,7 +160,7 @@ describe('react-create-class-integration', () => { it('should throw if a reserved property is in statics', () => { expect(function() { - ReactCreateClass({ + createReactClass({ statics: { getDefaultProps: function() { return { @@ -196,7 +185,7 @@ describe('react-create-class-integration', () => { xit('should warn when using deprecated non-static spec keys', () => { spyOn(console, 'error'); - ReactCreateClass({ + createReactClass({ mixins: [{}], propTypes: { foo: React.PropTypes.string, @@ -231,7 +220,7 @@ describe('react-create-class-integration', () => { }); it('should support statics', () => { - var Component = ReactCreateClass({ + var Component = createReactClass({ statics: { abc: 'def', def: 0, @@ -261,7 +250,7 @@ describe('react-create-class-integration', () => { }); it('should work with object getInitialState() return values', () => { - var Component = ReactCreateClass({ + var Component = createReactClass({ getInitialState: function() { return { occupation: 'clown', @@ -277,7 +266,7 @@ describe('react-create-class-integration', () => { }); it('renders based on context getInitialState', () => { - var Foo = ReactCreateClass({ + var Foo = createReactClass({ contextTypes: { className: React.PropTypes.string, }, @@ -289,7 +278,7 @@ describe('react-create-class-integration', () => { }, }); - var Outer = ReactCreateClass({ + var Outer = createReactClass({ childContextTypes: { className: React.PropTypes.string, }, @@ -308,7 +297,7 @@ describe('react-create-class-integration', () => { it('should throw with non-object getInitialState() return values', () => { [['an array'], 'a string', 1234].forEach(function(state) { - var Component = ReactCreateClass({ + var Component = createReactClass({ getInitialState: function() { return state; }, @@ -326,7 +315,7 @@ describe('react-create-class-integration', () => { }); it('should work with a null getInitialState() return value', () => { - var Component = ReactCreateClass({ + var Component = createReactClass({ getInitialState: function() { return null; }, @@ -340,7 +329,7 @@ describe('react-create-class-integration', () => { it('should throw when using legacy factories', () => { spyOn(console, 'error'); - var Component = ReactCreateClass({ + var Component = createReactClass({ render() { return
; }, @@ -356,7 +345,7 @@ describe('react-create-class-integration', () => { it('replaceState and callback works', () => { var ops = []; - var Component = ReactCreateClass({ + var Component = createReactClass({ getInitialState() { return {step: 0}; }, @@ -378,7 +367,7 @@ describe('react-create-class-integration', () => { var ops = []; var instance; - var Component = ReactCreateClass({ + var Component = createReactClass({ displayName: 'MyComponent', log(name) { ops.push(`${name}: ${this.isMounted()}`); diff --git a/yarn.lock b/yarn.lock index a48ed072bcdf5..681679cb60642 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1438,6 +1438,12 @@ create-hmac@^1.1.0, create-hmac@^1.1.2: create-hash "^1.1.0" inherits "^2.0.1" +create-react-class@^15.5.0: + version "15.5.0" + resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.5.0.tgz#7508ffcad56a0804fb244d6ff70b07648abfe5fb" + dependencies: + fbjs "^0.8.9" + cross-spawn-async@^2.2.2: version "2.2.5" resolved "https://registry.yarnpkg.com/cross-spawn-async/-/cross-spawn-async-2.2.5.tgz#845ff0c0834a3ded9d160daca6d390906bb288cc" @@ -4004,12 +4010,6 @@ rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-create-class@15.5.0-alpha.7: - version "15.5.0-alpha.7" - resolved "https://registry.yarnpkg.com/react-create-class/-/react-create-class-15.5.0-alpha.7.tgz#a2bf8846ab0f0e86799e8a2c2346d7a87941a350" - dependencies: - fbjs "^0.8.9" - read-only-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/read-only-stream/-/read-only-stream-2.0.0.tgz#2724fd6a8113d73764ac288d4386270c1dbf17f0"