react-create-class -> create-react-class
This commit is contained in:
parent
ce489262a1
commit
957fbc92b1
|
@ -43,6 +43,7 @@
|
||||||
"coffee-script": "^1.8.0",
|
"coffee-script": "^1.8.0",
|
||||||
"core-js": "^2.2.1",
|
"core-js": "^2.2.1",
|
||||||
"coveralls": "^2.11.6",
|
"coveralls": "^2.11.6",
|
||||||
|
"create-react-class": "^15.5.0",
|
||||||
"del": "^2.0.2",
|
"del": "^2.0.2",
|
||||||
"derequire": "^2.0.3",
|
"derequire": "^2.0.3",
|
||||||
"escape-string-regexp": "^1.0.5",
|
"escape-string-regexp": "^1.0.5",
|
||||||
|
|
|
@ -90,7 +90,7 @@ src/isomorphic/classic/__tests__/ReactContextValidator-test.js
|
||||||
* should warn (but not error) if getChildContext method is missing
|
* should warn (but not error) if getChildContext method is missing
|
||||||
* should pass parent context 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 throw when `render` is not specified
|
||||||
* should copy prop types onto the Constructor
|
* should copy prop types onto the Constructor
|
||||||
* should warn on invalid prop types
|
* should warn on invalid prop types
|
||||||
|
|
|
@ -102,7 +102,7 @@ if (__DEV__) {
|
||||||
warnedForCreateClass,
|
warnedForCreateClass,
|
||||||
'React.createClass is no longer supported. Use a plain JavaScript ' +
|
'React.createClass is no longer supported. Use a plain JavaScript ' +
|
||||||
"class instead. If you're not yet ready to migrate, " +
|
"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.',
|
'drop-in replacement.',
|
||||||
);
|
);
|
||||||
warnedForCreateClass = true;
|
warnedForCreateClass = true;
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe('React', () => {
|
||||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||||
'React.createClass is no longer supported. Use a plain ' +
|
'React.createClass is no longer supported. Use a plain ' +
|
||||||
"JavaScript class instead. If you're not yet ready to migrate, " +
|
"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.',
|
'drop-in replacement.',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,15 +14,15 @@
|
||||||
var React;
|
var React;
|
||||||
var ReactDOM;
|
var ReactDOM;
|
||||||
var ReactTestUtils;
|
var ReactTestUtils;
|
||||||
var ReactCreateClass;
|
var createReactClass;
|
||||||
|
|
||||||
describe('react-create-class-integration', () => {
|
describe('create-react-class-integration', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
React = require('React');
|
React = require('React');
|
||||||
ReactDOM = require('ReactDOM');
|
ReactDOM = require('ReactDOM');
|
||||||
ReactTestUtils = require('ReactTestUtils');
|
ReactTestUtils = require('ReactTestUtils');
|
||||||
var ReactCreateClassFactory = require('react-create-class/factory');
|
var createReactClassFactory = require('create-react-class/factory');
|
||||||
ReactCreateClass = ReactCreateClassFactory(
|
createReactClass = createReactClassFactory(
|
||||||
React.Component,
|
React.Component,
|
||||||
React.isValidElement,
|
React.isValidElement,
|
||||||
require('ReactNoopUpdateQueue'),
|
require('ReactNoopUpdateQueue'),
|
||||||
|
@ -31,26 +31,15 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('should throw when `render` is not specified', () => {
|
it('should throw when `render` is not specified', () => {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
ReactCreateClass({});
|
createReactClass({});
|
||||||
}).toThrowError(
|
}).toThrowError(
|
||||||
'createClass(...): Class specification must implement a `render` method.',
|
'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', () => {
|
it('should copy prop types onto the Constructor', () => {
|
||||||
var propValidator = jest.fn();
|
var propValidator = jest.fn();
|
||||||
var TestComponent = ReactCreateClass({
|
var TestComponent = createReactClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
value: propValidator,
|
value: propValidator,
|
||||||
},
|
},
|
||||||
|
@ -65,7 +54,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('should warn on invalid prop types', () => {
|
it('should warn on invalid prop types', () => {
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
ReactCreateClass({
|
createReactClass({
|
||||||
displayName: 'Component',
|
displayName: 'Component',
|
||||||
propTypes: {
|
propTypes: {
|
||||||
prop: null,
|
prop: null,
|
||||||
|
@ -83,7 +72,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('should warn on invalid context types', () => {
|
it('should warn on invalid context types', () => {
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
ReactCreateClass({
|
createReactClass({
|
||||||
displayName: 'Component',
|
displayName: 'Component',
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
prop: null,
|
prop: null,
|
||||||
|
@ -101,7 +90,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('should throw on invalid child context types', () => {
|
it('should throw on invalid child context types', () => {
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
ReactCreateClass({
|
createReactClass({
|
||||||
displayName: 'Component',
|
displayName: 'Component',
|
||||||
childContextTypes: {
|
childContextTypes: {
|
||||||
prop: null,
|
prop: null,
|
||||||
|
@ -120,7 +109,7 @@ describe('react-create-class-integration', () => {
|
||||||
it('should warn when mispelling shouldComponentUpdate', () => {
|
it('should warn when mispelling shouldComponentUpdate', () => {
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
|
|
||||||
ReactCreateClass({
|
createReactClass({
|
||||||
componentShouldUpdate: function() {
|
componentShouldUpdate: function() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -135,7 +124,7 @@ describe('react-create-class-integration', () => {
|
||||||
'because the function is expected to return a value.',
|
'because the function is expected to return a value.',
|
||||||
);
|
);
|
||||||
|
|
||||||
ReactCreateClass({
|
createReactClass({
|
||||||
displayName: 'NamedComponent',
|
displayName: 'NamedComponent',
|
||||||
componentShouldUpdate: function() {
|
componentShouldUpdate: function() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -154,7 +143,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('should warn when mispelling componentWillReceiveProps', () => {
|
it('should warn when mispelling componentWillReceiveProps', () => {
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
ReactCreateClass({
|
createReactClass({
|
||||||
componentWillRecieveProps: function() {
|
componentWillRecieveProps: function() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -171,7 +160,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('should throw if a reserved property is in statics', () => {
|
it('should throw if a reserved property is in statics', () => {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
ReactCreateClass({
|
createReactClass({
|
||||||
statics: {
|
statics: {
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
|
@ -196,7 +185,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
xit('should warn when using deprecated non-static spec keys', () => {
|
xit('should warn when using deprecated non-static spec keys', () => {
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
ReactCreateClass({
|
createReactClass({
|
||||||
mixins: [{}],
|
mixins: [{}],
|
||||||
propTypes: {
|
propTypes: {
|
||||||
foo: React.PropTypes.string,
|
foo: React.PropTypes.string,
|
||||||
|
@ -231,7 +220,7 @@ describe('react-create-class-integration', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support statics', () => {
|
it('should support statics', () => {
|
||||||
var Component = ReactCreateClass({
|
var Component = createReactClass({
|
||||||
statics: {
|
statics: {
|
||||||
abc: 'def',
|
abc: 'def',
|
||||||
def: 0,
|
def: 0,
|
||||||
|
@ -261,7 +250,7 @@ describe('react-create-class-integration', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with object getInitialState() return values', () => {
|
it('should work with object getInitialState() return values', () => {
|
||||||
var Component = ReactCreateClass({
|
var Component = createReactClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
occupation: 'clown',
|
occupation: 'clown',
|
||||||
|
@ -277,7 +266,7 @@ describe('react-create-class-integration', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders based on context getInitialState', () => {
|
it('renders based on context getInitialState', () => {
|
||||||
var Foo = ReactCreateClass({
|
var Foo = createReactClass({
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
@ -289,7 +278,7 @@ describe('react-create-class-integration', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var Outer = ReactCreateClass({
|
var Outer = createReactClass({
|
||||||
childContextTypes: {
|
childContextTypes: {
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
@ -308,7 +297,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('should throw with non-object getInitialState() return values', () => {
|
it('should throw with non-object getInitialState() return values', () => {
|
||||||
[['an array'], 'a string', 1234].forEach(function(state) {
|
[['an array'], 'a string', 1234].forEach(function(state) {
|
||||||
var Component = ReactCreateClass({
|
var Component = createReactClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return state;
|
return state;
|
||||||
},
|
},
|
||||||
|
@ -326,7 +315,7 @@ describe('react-create-class-integration', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with a null getInitialState() return value', () => {
|
it('should work with a null getInitialState() return value', () => {
|
||||||
var Component = ReactCreateClass({
|
var Component = createReactClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
@ -340,7 +329,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('should throw when using legacy factories', () => {
|
it('should throw when using legacy factories', () => {
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
var Component = ReactCreateClass({
|
var Component = createReactClass({
|
||||||
render() {
|
render() {
|
||||||
return <div />;
|
return <div />;
|
||||||
},
|
},
|
||||||
|
@ -356,7 +345,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
it('replaceState and callback works', () => {
|
it('replaceState and callback works', () => {
|
||||||
var ops = [];
|
var ops = [];
|
||||||
var Component = ReactCreateClass({
|
var Component = createReactClass({
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {step: 0};
|
return {step: 0};
|
||||||
},
|
},
|
||||||
|
@ -378,7 +367,7 @@ describe('react-create-class-integration', () => {
|
||||||
|
|
||||||
var ops = [];
|
var ops = [];
|
||||||
var instance;
|
var instance;
|
||||||
var Component = ReactCreateClass({
|
var Component = createReactClass({
|
||||||
displayName: 'MyComponent',
|
displayName: 'MyComponent',
|
||||||
log(name) {
|
log(name) {
|
||||||
ops.push(`${name}: ${this.isMounted()}`);
|
ops.push(`${name}: ${this.isMounted()}`);
|
12
yarn.lock
12
yarn.lock
|
@ -1438,6 +1438,12 @@ create-hmac@^1.1.0, create-hmac@^1.1.2:
|
||||||
create-hash "^1.1.0"
|
create-hash "^1.1.0"
|
||||||
inherits "^2.0.1"
|
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:
|
cross-spawn-async@^2.2.2:
|
||||||
version "2.2.5"
|
version "2.2.5"
|
||||||
resolved "https://registry.yarnpkg.com/cross-spawn-async/-/cross-spawn-async-2.2.5.tgz#845ff0c0834a3ded9d160daca6d390906bb288cc"
|
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"
|
minimist "^1.2.0"
|
||||||
strip-json-comments "~2.0.1"
|
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:
|
read-only-stream@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/read-only-stream/-/read-only-stream-2.0.0.tgz#2724fd6a8113d73764ac288d4386270c1dbf17f0"
|
resolved "https://registry.yarnpkg.com/read-only-stream/-/read-only-stream-2.0.0.tgz#2724fd6a8113d73764ac288d4386270c1dbf17f0"
|
||||||
|
|
Loading…
Reference in New Issue