Skip to content

Commit

Permalink
Fix issues/bugs introduced by merge conflict resolution
Browse files Browse the repository at this point in the history
**what is the change?:**
A couple of bugs and holes were introduced when cherry-picking facebook#9232 onto the 15.6 branch. This fixes them.
We also needed to add some logic from facebook#9399

**why make this change?:**
To keep tests passing and get this change working.

**test plan:**
`yarn test`

**issue:**
facebook#9398
  • Loading branch information
flarnie committed May 25, 2017
1 parent 4beb610 commit 5ab59ba
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 1,295 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"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",
"eslint": "^3.10.2",
Expand Down Expand Up @@ -72,7 +71,6 @@
"object-assign": "^4.1.1",
"platform": "^1.1.0",
"prettier": "^1.2.2",
"prop-types": "15.5.7",
"run-sequence": "^1.1.4",
"through2": "^2.0.0",
"tmp": "~0.0.28",
Expand All @@ -85,6 +83,10 @@
"node": "4.x || 5.x || 6.x || 7.x",
"npm": "2.x || 3.x || 4.x"
},
"dependencies": {
"create-react-class": "^15.5.2",
"prop-types": "^15.5.6"
},
"commonerConfig": {
"version": 7
},
Expand Down
20 changes: 6 additions & 14 deletions src/isomorphic/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
var ReactChildren = require('ReactChildren');
var ReactComponent = require('ReactComponent');
var ReactPureComponent = require('ReactPureComponent');
var ReactClass = require('ReactClass');
var ReactDOMFactories = require('ReactDOMFactories');
var ReactElement = require('ReactElement');
var ReactPropTypes = require('ReactPropTypes');
var ReactVersion = require('ReactVersion');

var createReactClass = require('createClass');
var onlyChild = require('onlyChild');
var warning = require('warning');

var createElement = ReactElement.createElement;
var createFactory = ReactElement.createFactory;
Expand Down Expand Up @@ -55,16 +56,6 @@ if (__DEV__) {
warnedForSpread = true;
return Object.assign.apply(null, arguments);
};

createMixin = function(mixin) {
lowPriorityWarning(
warnedForCreateMixin,
'React.createMixin is deprecated and should not be used. You ' +
'can use this mixin directly instead.',
);
warnedForCreateMixin = true;
return mixin;
};
}

var React = {
Expand All @@ -88,7 +79,7 @@ var React = {
// Classic

PropTypes: ReactPropTypes,
createClass: ReactClass.createClass,
createClass: createReactClass,
createFactory: createFactory,
createMixin: createMixin,

Expand All @@ -102,8 +93,9 @@ var React = {
__spread: __spread,
};

// TODO: Fix tests so that this deprecation warning doesn't cause failures.
if (__DEV__) {
let warnedForCreateMixin = false;
let warnedForCreateClass = false;
if (canDefineProperty) {
Object.defineProperty(React, 'PropTypes', {
get() {
Expand All @@ -127,7 +119,7 @@ if (__DEV__) {
'drop-in replacement.',
);
didWarnPropTypesDeprecated = true;
return ReactPropTypes;
return createReactClass;
},
});
}
Expand Down
14 changes: 13 additions & 1 deletion src/isomorphic/__tests__/React-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('React', () => {
spyOn(console, 'error');
let createClass = React.createClass;
createClass = React.createClass;
expect(createClass).toBe(undefined);
expect(createClass).not.toBe(undefined);
expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'React.createClass is no longer supported. Use a plain ' +
Expand All @@ -51,4 +51,16 @@ describe('React', () => {
'drop-in replacement.',
);
});

it('should warn once when attempting to access React.PropTypes', () => {
spyOn(console, 'error');
let PropTypes = React.PropTypes;
PropTypes = React.PropTypes;
expect(PropTypes).not.toBe(undefined);
expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'PropTypes have moved out of the react package. ' +
'Use the prop-types package from npm instead.',
);
});
});
Loading

0 comments on commit 5ab59ba

Please sign in to comment.