Skip to content

Commit 27bbbec

Browse files
committed
More fixes for issues introduced by rebasing
**what is the change?:** - Remove some outdated 'require' statements that got orphaned in 'React.js' - Change 'warning' to 'lowPriorityWarning' for 'React.createClass' - Fix syntax issues in 'React-test' - Use 'creatReactClass' instead of ES6 class in ReactART - Update 'prop-type' dependency to use no higher than 15.7 because 15.8 limits the number of warnings, and this causes a test to fail. - Fix some mixed-up and misnamed variables in `React.js` - Rebase onto commit that updates deprecation messages - Update a test based on new deprecation messages **why make this change?:** These were bugs introduced by rebasing and tests caught the regressions. **test plan:** `yarn test` **issue:** #9398
1 parent 3d1062b commit 27bbbec

File tree

7 files changed

+36
-31
lines changed

7 files changed

+36
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
},
8686
"dependencies": {
8787
"create-react-class": "^15.5.2",
88-
"prop-types": "^15.5.6"
88+
"prop-types": "15.5.7"
8989
},
9090
"commonerConfig": {
9191
"version": 7

src/isomorphic/React.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313

1414
var ReactBaseClasses = require('ReactBaseClasses');
1515
var ReactChildren = require('ReactChildren');
16-
var ReactComponent = require('ReactComponent');
17-
var ReactPureComponent = require('ReactPureComponent');
1816
var ReactDOMFactories = require('ReactDOMFactories');
1917
var ReactElement = require('ReactElement');
2018
var ReactPropTypes = require('ReactPropTypes');
2119
var ReactVersion = require('ReactVersion');
2220

2321
var createReactClass = require('createClass');
2422
var onlyChild = require('onlyChild');
25-
var warning = require('warning');
2623

2724
var createElement = ReactElement.createElement;
2825
var createFactory = ReactElement.createFactory;
@@ -107,7 +104,6 @@ var React = {
107104
};
108105

109106
if (__DEV__) {
110-
let warnedForCreateMixin = false;
111107
let warnedForCreateClass = false;
112108
if (canDefineProperty) {
113109
Object.defineProperty(React, 'PropTypes', {
@@ -128,14 +124,14 @@ if (__DEV__) {
128124

129125
Object.defineProperty(React, 'createClass', {
130126
get: function() {
131-
warning(
127+
lowPriorityWarning(
132128
warnedForCreateClass,
133129
'React.createClass is no longer supported. Use a plain JavaScript ' +
134130
"class instead. If you're not yet ready to migrate, " +
135131
'create-react-class is available on npm as a temporary, ' +
136132
'drop-in replacement.',
137133
);
138-
didWarnPropTypesDeprecated = true;
134+
warnedForCreateClass = true;
139135
return createReactClass;
140136
},
141137
});

src/isomorphic/__tests__/React-test.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ describe('React', () => {
3939
});
4040

4141
it('should warn once when attempting to access React.createClass', () => {
42-
spyOn(console, 'error');
42+
spyOn(console, 'warn');
4343
let createClass = React.createClass;
4444
createClass = React.createClass;
4545
expect(createClass).not.toBe(undefined);
46-
expectDev(console.error.calls.count()).toBe(1);
47-
expectDev(console.error.calls.argsFor(0)[0]).toContain(
46+
expect(console.warn.calls.count()).toBe(1);
47+
expect(console.warn.calls.argsFor(0)[0]).toContain(
4848
'React.createClass is no longer supported. Use a plain ' +
4949
"JavaScript class instead. If you're not yet ready to migrate, " +
5050
'create-react-class is available on npm as a temporary, ' +
@@ -53,14 +53,18 @@ describe('React', () => {
5353
});
5454

5555
it('should warn once when attempting to access React.PropTypes', () => {
56-
spyOn(console, 'error');
56+
spyOn(console, 'warn');
5757
let PropTypes = React.PropTypes;
5858
PropTypes = React.PropTypes;
5959
expect(PropTypes).not.toBe(undefined);
60-
expectDev(console.error.calls.count()).toBe(1);
61-
expectDev(console.error.calls.argsFor(0)[0]).toContain(
62-
'PropTypes have moved out of the react package. ' +
63-
'Use the prop-types package from npm instead.',
60+
expect(console.warn.calls.count()).toBe(1);
61+
expect(console.warn.calls.argsFor(0)[0]).toContain(
62+
'Warning: Accessing PropTypes via the main React package is ' +
63+
'deprecated, and will be removed in React v16.0. ' +
64+
'Use the prop-types package from npm instead. ' +
65+
'Version 15.5.10 provides a drop-in replacement. ' +
66+
'For info on usage, compatibility, migration and more, ' +
67+
'see https://fb.me/prop-types-docs',
6468
);
6569
});
6670
});

src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ describe('create-react-class-integration', () => {
324324
},
325325
});
326326
expect(() =>
327-
ReactTestUtils.renderIntoDocument(<Component />)).not.toThrow();
327+
ReactTestUtils.renderIntoDocument(<Component />),
328+
).not.toThrow();
328329
});
329330

330331
it('should throw when using legacy factories', () => {

src/renderers/art/ReactART.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const ReactInstanceMap = require('ReactInstanceMap');
2424
const ReactMultiChild = require('ReactMultiChild');
2525
const ReactUpdates = require('ReactUpdates');
2626

27+
const createReactClass = require('createClass');
2728
const emptyObject = require('emptyObject');
2829
const invariant = require('invariant');
2930

@@ -171,8 +172,12 @@ const ContainerMixin = assign({}, ReactMultiChild.Mixin, {
171172
// Surface is a React DOM Component, not an ART component. It serves as the
172173
// entry point into the ART reconciler.
173174

174-
class Surface extends React.Component {
175-
componentDidMount() {
175+
const Surface = createReactClass({
176+
displayName: 'Surface',
177+
178+
mixins: [ContainerMixin],
179+
180+
componentDidMount: function() {
176181
const domNode = ReactDOM.findDOMNode(this);
177182

178183
this.node = Mode.Surface(+this.props.width, +this.props.height, domNode);
@@ -186,9 +191,9 @@ class Surface extends React.Component {
186191
ReactInstanceMap.get(this)._context,
187192
);
188193
ReactUpdates.ReactReconcileTransaction.release(transaction);
189-
}
194+
},
190195

191-
componentDidUpdate(oldProps) {
196+
componentDidUpdate: function(oldProps) {
192197
const node = this.node;
193198
if (
194199
this.props.width != oldProps.width ||
@@ -210,13 +215,13 @@ class Surface extends React.Component {
210215
if (node.render) {
211216
node.render();
212217
}
213-
}
218+
},
214219

215-
componentWillUnmount() {
220+
componentWillUnmount: function() {
216221
this.unmountChildren();
217-
}
222+
},
218223

219-
render() {
224+
render: function() {
220225
// This is going to be a placeholder because we don't know what it will
221226
// actually resolve to because ART may render canvas, vml or svg tags here.
222227
// We only allow a subset of properties since others might conflict with
@@ -234,8 +239,8 @@ class Surface extends React.Component {
234239
title={props.title}
235240
/>
236241
);
237-
}
238-
}
242+
},
243+
});
239244

240245
// Various nodes that can go into a surface
241246

src/renderers/shared/utils/Transaction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ var TransactionImpl = {
134134
E,
135135
F,
136136
G,
137-
T: (a: A, b: B, c: C, d: D, e: E, f: F) => G
137+
T: (a: A, b: B, c: C, d: D, e: E, f: F) => G,
138138
>(method: T, scope: any, a: A, b: B, c: C, d: D, e: E, f: F): G {
139139
/* eslint-enable space-before-function-paren */
140140
invariant(

yarn.lock

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4293,12 +4293,11 @@ promise@^7.1.1:
42934293
dependencies:
42944294
asap "~2.0.3"
42954295

4296-
prop-types@^15.5.6:
4297-
version "15.5.10"
4298-
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
4296+
4297+
version "15.5.7"
4298+
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.7.tgz#231c4f29cdd82e355011d4889386ca9059544dd1"
42994299
dependencies:
43004300
fbjs "^0.8.9"
4301-
loose-envify "^1.3.1"
43024301

43034302
prr@~0.0.0:
43044303
version "0.0.0"

0 commit comments

Comments
 (0)