react-create-class -> create-react-class

This commit is contained in:
Andrew Clark 2017-04-07 15:17:15 -07:00
parent ce489262a1
commit 957fbc92b1
6 changed files with 33 additions and 43 deletions

View File

@ -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",

View File

@ -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

View File

@ -102,7 +102,7 @@ if (__DEV__) {
warnedForCreateClass,
'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.',
);
warnedForCreateClass = true;

View File

@ -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.',
);
});

View File

@ -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 <div />;
},
});
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 <div />;
},
@ -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()}`);

View File

@ -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"