@samitouri / QOS-React-2 / commits / fedb2ff8ec

Remove createClass, PropTypes, DOM factories, and createMixin from React object (#9788)

Dan Abramov committed May 30, 2017 at 15:35 UTC fedb2ff8ecd96d11ff3f609fbffa76848203f255
12 files changed +75 -1769
packages/react/package.json
-1
@@ -22,7 +22,6 @@
22 "node": ">=0.10.0"
23 },
24 "dependencies": {
25 - "create-react-class": "^15.5.2",
25 "fbjs": "^0.8.9",
26 "loose-envify": "^1.1.0",
27 "object-assign": "^4.1.0",
scripts/fiber/tests-passing.txt
+1 -94
@@ -40,16 +40,6 @@ scripts/shared/__tests__/evalToString-test.js
40 * should support string concat (`+`)
41 * should throw when it finds other types
42
43 -src/addons/__tests__/ReactDOMFactories-test.js
44 -* allow factories to be called without warnings
45 -* warns once when accessing React.DOM methods
46 -
47 -src/isomorphic/__tests__/React-test.js
48 -* should log a deprecation warning once when using React.createMixin
49 -* should warn once when attempting to access React.createClass
50 -* should warn once when attempting to access React.PropTypes
51 -* should warn once when attempting to access React.checkPropTypes
52 -
43 src/isomorphic/children/__tests__/ReactChildren-test.js
44 * should support identity for simple
45 * should treat single arrayless child as being in array
@@ -98,7 +88,7 @@ src/isomorphic/classic/__tests__/ReactContextValidator-test.js
88 * should warn (but not error) if getChildContext method is missing
89 * should pass parent context if getChildContext method is missing
90
101 -src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js
91 +src/isomorphic/classic/__tests__/createReactClassIntegration-test.js
92 * should throw when `render` is not specified
93 * should copy prop types onto the Constructor
94 * should warn on invalid prop types
@@ -203,89 +193,6 @@ src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
193 * does not blow up with inlined children
194 * does not blow up on key warning with undefined type
195
206 -src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
207 -* does not return a value from a validator
208 -* does not throw if validator throws
209 -* should warn for invalid strings
210 -* should fail date and regexp correctly
211 -* should not warn for valid values
212 -* should be implicitly optional and not warn without values
213 -* should warn for missing required values
214 -* should throw if called manually in development
215 -* should should accept any value
216 -* should be implicitly optional and not warn without values
217 -* should warn for missing required values
218 -* should throw if called manually in development
219 -* should fail for invalid argument
220 -* should support the arrayOf propTypes
221 -* should support arrayOf with complex types
222 -* should warn with invalid items in the array
223 -* should warn with invalid complex types
224 -* should warn when passed something other than an array
225 -* should not warn when passing an empty array
226 -* should be implicitly optional and not warn without values
227 -* should warn for missing required values
228 -* should throw if called manually in development
229 -* should support components
230 -* should not support multiple components or scalar values
231 -* should be able to define a single child as label
232 -* should warn when passing no label and isRequired is set
233 -* should be implicitly optional and not warn without values
234 -* should warn for missing required values
235 -* should throw if called manually in development
236 -* should warn for invalid instances
237 -* should not warn for valid values
238 -* should be implicitly optional and not warn without values
239 -* should warn for missing required values
240 -* should throw if called manually in development
241 -* should warn for invalid values
242 -* should not warn for valid values
243 -* should not warn for iterables
244 -* should not warn for entry iterables
245 -* should not warn for null/undefined if not required
246 -* should warn for missing required values
247 -* should accept empty array for required props
248 -* should throw if called manually in development
249 -* should fail for invalid argument
250 -* should support the objectOf propTypes
251 -* should support objectOf with complex types
252 -* should warn with invalid items in the object
253 -* should warn with invalid complex types
254 -* should warn when passed something other than an object
255 -* should not warn when passing an empty object
256 -* should be implicitly optional and not warn without values
257 -* should warn for missing required values
258 -* should throw if called manually in development
259 -* should warn but not error for invalid argument
260 -* should warn for invalid values
261 -* should not warn for valid values
262 -* should be implicitly optional and not warn without values
263 -* should warn for missing required values
264 -* should throw if called manually in development
265 -* should warn but not error for invalid argument
266 -* should warn if none of the types are valid
267 -* should not warn if one of the types are valid
268 -* should be implicitly optional and not warn without values
269 -* should warn for missing required values
270 -* should throw if called manually in development
271 -* should warn for non objects
272 -* should not warn for empty values
273 -* should not warn for an empty object
274 -* should not warn for non specified types
275 -* should not warn for valid types
276 -* should warn for required valid types
277 -* should warn for the first required type
278 -* should warn for invalid key types
279 -* should be implicitly optional and not warn without values
280 -* should warn for missing required values
281 -* should throw if called manually in development
282 -* should warn for non-symbol
283 -* should not warn for a polyfilled Symbol
284 -* should have been called with the right params
285 -* should have been called even if the prop is not present
286 -* should have received the validator's return value
287 -* should not warn if the validator returned null
288 -
196 src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js
197 * tests the same thing for es6 classes and CoffeeScript
198 * tests the same thing for es6 classes and TypeScript
scripts/rollup/results.json
+44 -44
@@ -1,28 +1,28 @@
1 {
2 "bundleSizes": {
3 "react.development.js (UMD_DEV)": {
4 - "size": 125800,
5 - "gzip": 31378
4 + "size": 73848,
5 + "gzip": 18852
6 },
7 "react.production.min.js (UMD_PROD)": {
8 - "size": 15753,
9 - "gzip": 5824
8 + "size": 7756,
9 + "gzip": 3089
10 },
11 "react-dom.development.js (UMD_DEV)": {
12 - "size": 605005,
13 - "gzip": 139056
12 + "size": 605435,
13 + "gzip": 139358
14 },
15 "react-dom.production.min.js (UMD_PROD)": {
16 - "size": 125182,
17 - "gzip": 39533
16 + "size": 125246,
17 + "gzip": 39624
18 },
19 "react-dom-server.development.js (UMD_DEV)": {
20 - "size": 525947,
21 - "gzip": 126689
20 + "size": 534438,
21 + "gzip": 129160
22 },
23 "react-dom-server.production.min.js (UMD_PROD)": {
24 - "size": 111505,
25 - "gzip": 34936
24 + "size": 113386,
25 + "gzip": 35642
26 },
27 "react-art.development.js (UMD_DEV)": {
28 "size": 359125,
@@ -33,60 +33,60 @@
33 "gzip": 29993
34 },
35 "react.development.js (NODE_DEV)": {
36 - "size": 72595,
37 - "gzip": 18499
36 + "size": 64064,
37 + "gzip": 16441
38 },
39 "react.production.min.js (NODE_PROD)": {
40 - "size": 9195,
41 - "gzip": 3614
40 + "size": 6650,
41 + "gzip": 2671
42 },
43 "React-dev.js (FB_DEV)": {
44 - "size": 71806,
45 - "gzip": 18233
44 + "size": 63268,
45 + "gzip": 16164
46 },
47 "React-prod.js (FB_PROD)": {
48 - "size": 36172,
49 - "gzip": 9226
48 + "size": 30387,
49 + "gzip": 7986
50 },
51 "ReactDOMStack-dev.js (FB_DEV)": {
52 - "size": 495315,
53 - "gzip": 118265
52 + "size": 503788,
53 + "gzip": 120786
54 },
55 "ReactDOMStack-prod.js (FB_PROD)": {
56 - "size": 353140,
57 - "gzip": 84785
56 + "size": 360176,
57 + "gzip": 86700
58 },
59 "react-dom.development.js (NODE_DEV)": {
60 - "size": 562575,
61 - "gzip": 128975
60 + "size": 563003,
61 + "gzip": 129288
62 },
63 "react-dom.production.min.js (NODE_PROD)": {
64 - "size": 121395,
65 - "gzip": 38183
64 + "size": 121459,
65 + "gzip": 38279
66 },
67 "ReactDOMFiber-dev.js (FB_DEV)": {
68 - "size": 563564,
69 - "gzip": 129481
68 + "size": 563992,
69 + "gzip": 129811
70 },
71 "ReactDOMFiber-prod.js (FB_PROD)": {
72 - "size": 422947,
73 - "gzip": 96357
72 + "size": 423415,
73 + "gzip": 96616
74 },
75 "react-dom-server.development.js (NODE_DEV)": {
76 - "size": 474510,
77 - "gzip": 114092
76 + "size": 482987,
77 + "gzip": 116600
78 },
79 "react-dom-server.production.min.js (NODE_PROD)": {
80 - "size": 105880,
81 - "gzip": 32763
80 + "size": 107761,
81 + "gzip": 33495
82 },
83 "ReactDOMServerStack-dev.js (FB_DEV)": {
84 - "size": 455996,
85 - "gzip": 109840
84 + "size": 464469,
85 + "gzip": 112326
86 },
87 "ReactDOMServerStack-prod.js (FB_PROD)": {
88 - "size": 334101,
89 - "gzip": 80467
88 + "size": 341137,
89 + "gzip": 82395
90 },
91 "ReactARTStack-dev.js (FB_DEV)": {
92 "size": 143177,
@@ -157,12 +157,12 @@
157 "gzip": 2234
158 },
159 "ReactDOMServerStream-dev.js (FB_DEV)": {
160 - "size": 472979,
161 - "gzip": 113937
160 + "size": 481456,
161 + "gzip": 116430
162 },
163 "ReactDOMServerStream-prod.js (FB_PROD)": {
164 - "size": 345258,
165 - "gzip": 83320
164 + "size": 352294,
165 + "gzip": 85249
166 },
167 "ReactNativeStack-dev.js (RN_DEV)": {
168 "size": 182305,
src/addons/ReactDOMFactories.js deleted
-169
@@ -1,169 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule ReactDOMFactories
10 - */
11 -
12 -'use strict';
13 -
14 -var ReactElement = require('ReactElement');
15 -
16 -/**
17 - * Create a factory that creates HTML tag elements.
18 - *
19 - * @private
20 - */
21 -var createDOMFactory = ReactElement.createFactory;
22 -if (__DEV__) {
23 - var ReactElementValidator = require('ReactElementValidator');
24 - createDOMFactory = ReactElementValidator.createFactory;
25 -}
26 -
27 -/**
28 - * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
29 - *
30 - * @public
31 - */
32 -var ReactDOMFactories = {
33 - a: createDOMFactory('a'),
34 - abbr: createDOMFactory('abbr'),
35 - address: createDOMFactory('address'),
36 - area: createDOMFactory('area'),
37 - article: createDOMFactory('article'),
38 - aside: createDOMFactory('aside'),
39 - audio: createDOMFactory('audio'),
40 - b: createDOMFactory('b'),
41 - base: createDOMFactory('base'),
42 - bdi: createDOMFactory('bdi'),
43 - bdo: createDOMFactory('bdo'),
44 - big: createDOMFactory('big'),
45 - blockquote: createDOMFactory('blockquote'),
46 - body: createDOMFactory('body'),
47 - br: createDOMFactory('br'),
48 - button: createDOMFactory('button'),
49 - canvas: createDOMFactory('canvas'),
50 - caption: createDOMFactory('caption'),
51 - cite: createDOMFactory('cite'),
52 - code: createDOMFactory('code'),
53 - col: createDOMFactory('col'),
54 - colgroup: createDOMFactory('colgroup'),
55 - data: createDOMFactory('data'),
56 - datalist: createDOMFactory('datalist'),
57 - dd: createDOMFactory('dd'),
58 - del: createDOMFactory('del'),
59 - details: createDOMFactory('details'),
60 - dfn: createDOMFactory('dfn'),
61 - dialog: createDOMFactory('dialog'),
62 - div: createDOMFactory('div'),
63 - dl: createDOMFactory('dl'),
64 - dt: createDOMFactory('dt'),
65 - em: createDOMFactory('em'),
66 - embed: createDOMFactory('embed'),
67 - fieldset: createDOMFactory('fieldset'),
68 - figcaption: createDOMFactory('figcaption'),
69 - figure: createDOMFactory('figure'),
70 - footer: createDOMFactory('footer'),
71 - form: createDOMFactory('form'),
72 - h1: createDOMFactory('h1'),
73 - h2: createDOMFactory('h2'),
74 - h3: createDOMFactory('h3'),
75 - h4: createDOMFactory('h4'),
76 - h5: createDOMFactory('h5'),
77 - h6: createDOMFactory('h6'),
78 - head: createDOMFactory('head'),
79 - header: createDOMFactory('header'),
80 - hgroup: createDOMFactory('hgroup'),
81 - hr: createDOMFactory('hr'),
82 - html: createDOMFactory('html'),
83 - i: createDOMFactory('i'),
84 - iframe: createDOMFactory('iframe'),
85 - img: createDOMFactory('img'),
86 - input: createDOMFactory('input'),
87 - ins: createDOMFactory('ins'),
88 - kbd: createDOMFactory('kbd'),
89 - keygen: createDOMFactory('keygen'),
90 - label: createDOMFactory('label'),
91 - legend: createDOMFactory('legend'),
92 - li: createDOMFactory('li'),
93 - link: createDOMFactory('link'),
94 - main: createDOMFactory('main'),
95 - map: createDOMFactory('map'),
96 - mark: createDOMFactory('mark'),
97 - menu: createDOMFactory('menu'),
98 - menuitem: createDOMFactory('menuitem'),
99 - meta: createDOMFactory('meta'),
100 - meter: createDOMFactory('meter'),
101 - nav: createDOMFactory('nav'),
102 - noscript: createDOMFactory('noscript'),
103 - object: createDOMFactory('object'),
104 - ol: createDOMFactory('ol'),
105 - optgroup: createDOMFactory('optgroup'),
106 - option: createDOMFactory('option'),
107 - output: createDOMFactory('output'),
108 - p: createDOMFactory('p'),
109 - param: createDOMFactory('param'),
110 - picture: createDOMFactory('picture'),
111 - pre: createDOMFactory('pre'),
112 - progress: createDOMFactory('progress'),
113 - q: createDOMFactory('q'),
114 - rp: createDOMFactory('rp'),
115 - rt: createDOMFactory('rt'),
116 - ruby: createDOMFactory('ruby'),
117 - s: createDOMFactory('s'),
118 - samp: createDOMFactory('samp'),
119 - script: createDOMFactory('script'),
120 - section: createDOMFactory('section'),
121 - select: createDOMFactory('select'),
122 - small: createDOMFactory('small'),
123 - source: createDOMFactory('source'),
124 - span: createDOMFactory('span'),
125 - strong: createDOMFactory('strong'),
126 - style: createDOMFactory('style'),
127 - sub: createDOMFactory('sub'),
128 - summary: createDOMFactory('summary'),
129 - sup: createDOMFactory('sup'),
130 - table: createDOMFactory('table'),
131 - tbody: createDOMFactory('tbody'),
132 - td: createDOMFactory('td'),
133 - textarea: createDOMFactory('textarea'),
134 - tfoot: createDOMFactory('tfoot'),
135 - th: createDOMFactory('th'),
136 - thead: createDOMFactory('thead'),
137 - time: createDOMFactory('time'),
138 - title: createDOMFactory('title'),
139 - tr: createDOMFactory('tr'),
140 - track: createDOMFactory('track'),
141 - u: createDOMFactory('u'),
142 - ul: createDOMFactory('ul'),
143 - var: createDOMFactory('var'),
144 - video: createDOMFactory('video'),
145 - wbr: createDOMFactory('wbr'),
146 -
147 - // SVG
148 - circle: createDOMFactory('circle'),
149 - clipPath: createDOMFactory('clipPath'),
150 - defs: createDOMFactory('defs'),
151 - ellipse: createDOMFactory('ellipse'),
152 - g: createDOMFactory('g'),
153 - image: createDOMFactory('image'),
154 - line: createDOMFactory('line'),
155 - linearGradient: createDOMFactory('linearGradient'),
156 - mask: createDOMFactory('mask'),
157 - path: createDOMFactory('path'),
158 - pattern: createDOMFactory('pattern'),
159 - polygon: createDOMFactory('polygon'),
160 - polyline: createDOMFactory('polyline'),
161 - radialGradient: createDOMFactory('radialGradient'),
162 - rect: createDOMFactory('rect'),
163 - stop: createDOMFactory('stop'),
164 - svg: createDOMFactory('svg'),
165 - text: createDOMFactory('text'),
166 - tspan: createDOMFactory('tspan'),
167 -};
168 -
169 -module.exports = ReactDOMFactories;
src/addons/__tests__/ReactDOMFactories-test.js deleted
-41
@@ -1,41 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @emails react-core
10 - */
11 -
12 -'use strict';
13 -
14 -var React = require('React');
15 -var {div} = require('ReactDOMFactories');
16 -
17 -describe('ReactDOMFactories', () => {
18 - it('allow factories to be called without warnings', () => {
19 - spyOn(console, 'error');
20 - spyOn(console, 'warn');
21 - var element = div();
22 - expect(element.type).toBe('div');
23 - expect(console.error).not.toHaveBeenCalled();
24 - expect(console.warn).not.toHaveBeenCalled();
25 - });
26 -
27 - it('warns once when accessing React.DOM methods', () => {
28 - spyOn(console, 'warn');
29 -
30 - var a = React.DOM.a();
31 - var p = React.DOM.p();
32 -
33 - expect(a.type).toBe('a');
34 - expect(p.type).toBe('p');
35 -
36 - expect(console.warn).toHaveBeenCalledTimes(1);
37 - expect(console.warn.calls.first().args[0]).toContain(
38 - 'Warning: Accessing factories like React.DOM.a has been deprecated',
39 - );
40 - });
41 -});
src/isomorphic/React.js
-107
@@ -13,35 +13,23 @@
13
14 var ReactBaseClasses = require('ReactBaseClasses');
15 var ReactChildren = require('ReactChildren');
16 -var ReactDOMFactories = require('ReactDOMFactories');
16 var ReactElement = require('ReactElement');
18 -var ReactPropTypes = require('ReactPropTypes');
17 var ReactVersion = require('ReactVersion');
18
19 var onlyChild = require('onlyChild');
22 -var checkPropTypes = require('prop-types/checkPropTypes');
23 -var createReactClass = require('createClass');
20
21 var createElement = ReactElement.createElement;
22 var createFactory = ReactElement.createFactory;
23 var cloneElement = ReactElement.cloneElement;
24
25 if (__DEV__) {
30 - var lowPriorityWarning = require('lowPriorityWarning');
31 - var canDefineProperty = require('canDefineProperty');
26 var ReactElementValidator = require('ReactElementValidator');
27 createElement = ReactElementValidator.createElement;
28 createFactory = ReactElementValidator.createFactory;
29 cloneElement = ReactElementValidator.cloneElement;
30 }
31
38 -var createMixin = function(mixin) {
39 - return mixin;
40 -};
41 -
32 var React = {
43 - // Modern
44 -
33 Children: {
34 map: ReactChildren.map,
35 forEach: ReactChildren.forEach,
@@ -57,19 +45,7 @@ var React = {
45 cloneElement: cloneElement,
46 isValidElement: ReactElement.isValidElement,
47
60 - // TODO (bvaughn) Remove these getters before 16.0.0
61 - PropTypes: ReactPropTypes,
62 - checkPropTypes: checkPropTypes,
63 - createClass: createReactClass,
64 -
65 - // Classic
66 -
48 createFactory: createFactory,
68 - createMixin: createMixin,
69 -
70 - // This looks DOM specific but these are actually isomorphic helpers
71 - // since they are just generating DOM strings.
72 - DOM: ReactDOMFactories,
49
50 version: ReactVersion,
51
@@ -84,89 +60,6 @@ if (__DEV__) {
60 ReactComponentTreeHook: require('ReactComponentTreeHook'),
61 ReactDebugCurrentFrame: require('ReactDebugCurrentFrame'),
62 });
87 -
88 - let warnedForCheckPropTypes = false;
89 - let warnedForCreateMixin = false;
90 - let warnedForCreateClass = false;
91 - let warnedForPropTypes = false;
92 -
93 - React.createMixin = function(mixin) {
94 - lowPriorityWarning(
95 - warnedForCreateMixin,
96 - 'React.createMixin is deprecated and should not be used. You ' +
97 - 'can use this mixin directly instead.',
98 - );
99 - warnedForCreateMixin = true;
100 - return mixin;
101 - };
102 -
103 - // TODO (bvaughn) Remove all of these accessors before 16.0.0
104 - if (canDefineProperty) {
105 - Object.defineProperty(React, 'checkPropTypes', {
106 - get() {
107 - lowPriorityWarning(
108 - warnedForCheckPropTypes,
109 - 'checkPropTypes has been moved to a separate package. ' +
110 - 'Accessing React.checkPropTypes is no longer supported ' +
111 - 'and will be removed completely in React 16. ' +
112 - 'Use the prop-types package on npm instead. ' +
113 - '(https://fb.me/migrating-from-react-proptypes)',
114 - );
115 - warnedForCheckPropTypes = true;
116 - return checkPropTypes;
117 - },
118 - });
119 -
120 - Object.defineProperty(React, 'createClass', {
121 - get: function() {
122 - lowPriorityWarning(
123 - warnedForCreateClass,
124 - 'React.createClass is no longer supported. Use a plain JavaScript ' +
125 - "class instead. If you're not yet ready to migrate, " +
126 - 'create-react-class is available on npm as a drop-in replacement. ' +
127 - '(https://fb.me/migrating-from-react-create-class)',
128 - );
129 - warnedForCreateClass = true;
130 - return createReactClass;
131 - },
132 - });
133 -
134 - Object.defineProperty(React, 'PropTypes', {
135 - get() {
136 - lowPriorityWarning(
137 - warnedForPropTypes,
138 - 'PropTypes has been moved to a separate package. ' +
139 - 'Accessing React.PropTypes is no longer supported ' +
140 - 'and will be removed completely in React 16. ' +
141 - 'Use the prop-types package on npm instead. ' +
142 - '(https://fb.me/migrating-from-react-proptypes)',
143 - );
144 - warnedForPropTypes = true;
145 - return ReactPropTypes;
146 - },
147 - });
148 - }
149 -
150 - // React.DOM factories are deprecated. Wrap these methods so that
151 - // invocations of the React.DOM namespace and alert users to switch
152 - // to the `react-addons-dom-factories` package.
153 - React.DOM = {};
154 - var warnedForFactories = false;
155 - Object.keys(ReactDOMFactories).forEach(function(factory) {
156 - React.DOM[factory] = function(...args) {
157 - if (!warnedForFactories) {
158 - lowPriorityWarning(
159 - false,
160 - 'Accessing factories like React.DOM.%s has been deprecated ' +
161 - 'and will be removed in the future. Use the ' +
162 - 'react-addons-dom-factories package instead.',
163 - factory,
164 - );
165 - warnedForFactories = true;
166 - }
167 - return ReactDOMFactories[factory](...args);
168 - };
169 - });
63 }
64
65 module.exports = React;
src/isomorphic/__tests__/React-test.js deleted
-74
@@ -1,74 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @emails react-core
10 - */
11 -
12 -'use strict';
13 -
14 -describe('React', () => {
15 - var React;
16 -
17 - beforeEach(() => {
18 - React = require('react');
19 - });
20 -
21 - it('should log a deprecation warning once when using React.createMixin', () => {
22 - spyOn(console, 'warn');
23 - React.createMixin();
24 - React.createMixin();
25 - expectDev(console.warn.calls.count()).toBe(1);
26 - expectDev(console.warn.calls.argsFor(0)[0]).toContain(
27 - 'React.createMixin is deprecated and should not be used',
28 - );
29 - });
30 -
31 - it('should warn once when attempting to access React.createClass', () => {
32 - spyOn(console, 'warn');
33 - let createClass = React.createClass;
34 - createClass = React.createClass;
35 - expect(createClass).not.toBe(undefined);
36 - expectDev(console.warn.calls.count()).toBe(1);
37 - expectDev(console.warn.calls.argsFor(0)[0]).toContain(
38 - 'React.createClass is no longer supported. Use a plain JavaScript ' +
39 - "class instead. If you're not yet ready to migrate, " +
40 - 'create-react-class is available on npm as a drop-in replacement. ' +
41 - '(https://fb.me/migrating-from-react-create-class)',
42 - );
43 - });
44 -
45 - it('should warn once when attempting to access React.PropTypes', () => {
46 - spyOn(console, 'warn');
47 - let PropTypes = React.PropTypes;
48 - PropTypes = React.PropTypes;
49 - expect(PropTypes).not.toBe(undefined);
50 - expectDev(console.warn.calls.count()).toBe(1);
51 - expectDev(console.warn.calls.argsFor(0)[0]).toContain(
52 - 'PropTypes has been moved to a separate package. ' +
53 - 'Accessing React.PropTypes is no longer supported ' +
54 - 'and will be removed completely in React 16. ' +
55 - 'Use the prop-types package on npm instead. ' +
56 - '(https://fb.me/migrating-from-react-proptypes)',
57 - );
58 - });
59 -
60 - it('should warn once when attempting to access React.checkPropTypes', () => {
61 - spyOn(console, 'warn');
62 - let checkPropTypes = React.checkPropTypes;
63 - checkPropTypes = React.checkPropTypes;
64 - expect(checkPropTypes).not.toBe(undefined);
65 - expectDev(console.warn.calls.count()).toBe(1);
66 - expectDev(console.warn.calls.argsFor(0)[0]).toContain(
67 - 'checkPropTypes has been moved to a separate package. ' +
68 - 'Accessing React.checkPropTypes is no longer supported ' +
69 - 'and will be removed completely in React 16. ' +
70 - 'Use the prop-types package on npm instead. ' +
71 - '(https://fb.me/migrating-from-react-proptypes)',
72 - );
73 - });
74 -});
src/isomorphic/classic/__tests__/createReactClassIntegration-test.js renamed
+2 -3
@@ -23,11 +23,10 @@ describe('create-react-class-integration', () => {
23 React = require('react');
24 ReactDOM = require('react-dom');
25 ReactTestUtils = require('ReactTestUtils');
26 - var createReactClassFactory = require('create-react-class/factory');
27 - createReactClass = createReactClassFactory(
26 + createReactClass = require('create-react-class/factory')(
27 React.Component,
28 React.isValidElement,
30 - require('ReactNoopUpdateQueue'),
29 + new React.Component().updater,
30 );
31 });
32
src/isomorphic/classic/class/createClass.js deleted
-19
@@ -1,19 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule createClass
10 - */
11 -
12 -'use strict';
13 -
14 -var {Component} = require('ReactBaseClasses');
15 -var {isValidElement} = require('ReactElement');
16 -var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');
17 -var factory = require('create-react-class/factory');
18 -
19 -module.exports = factory(Component, isValidElement, ReactNoopUpdateQueue);
src/isomorphic/classic/types/ReactPropTypes.js deleted
-14
@@ -1,14 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule ReactPropTypes
10 - */
11 -
12 -'use strict';
13 -
14 -module.exports = require('prop-types');
src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js deleted
-1175
@@ -1,1175 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @emails react-core
10 - */
11 -
12 -'use strict';
13 -
14 -var PropTypes;
15 -var checkPropTypes;
16 -var React;
17 -var ReactDOM;
18 -
19 -var Component;
20 -var MyComponent;
21 -
22 -function resetWarningCache() {
23 - jest.resetModules();
24 - checkPropTypes = require('prop-types/checkPropTypes');
25 - PropTypes = require('ReactPropTypes');
26 -}
27 -
28 -function getPropTypeWarningMessage(propTypes, object, componentName) {
29 - if (!console.error.calls) {
30 - spyOn(console, 'error');
31 - } else {
32 - console.error.calls.reset();
33 - }
34 - resetWarningCache();
35 - checkPropTypes(propTypes, object, 'prop', 'testComponent');
36 - const callCount = console.error.calls.count();
37 - if (callCount > 1) {
38 - throw new Error('Too many warnings.');
39 - }
40 - const message = console.error.calls.argsFor(0)[0] || null;
41 - console.error.calls.reset();
42 -
43 - return message;
44 -}
45 -
46 -function typeCheckFail(declaration, value, expectedMessage) {
47 - const propTypes = {
48 - testProp: declaration,
49 - };
50 - const props = {
51 - testProp: value,
52 - };
53 - const message = getPropTypeWarningMessage(propTypes, props, 'testComponent');
54 - expect(message).toContain(expectedMessage);
55 -}
56 -
57 -function typeCheckFailRequiredValues(declaration) {
58 - var specifiedButIsNullMsg =
59 - 'The prop `testProp` is marked as required in ' +
60 - '`testComponent`, but its value is `null`.';
61 - var unspecifiedMsg =
62 - 'The prop `testProp` is marked as required in ' +
63 - '`testComponent`, but its value is \`undefined\`.';
64 -
65 - var propTypes = {testProp: declaration};
66 -
67 - // Required prop is null
68 - var message1 = getPropTypeWarningMessage(
69 - propTypes,
70 - {testProp: null},
71 - 'testComponent',
72 - );
73 - expect(message1).toContain(specifiedButIsNullMsg);
74 -
75 - // Required prop is undefined
76 - var message2 = getPropTypeWarningMessage(
77 - propTypes,
78 - {testProp: undefined},
79 - 'testComponent',
80 - );
81 - expect(message2).toContain(unspecifiedMsg);
82 -
83 - // Required prop is not a member of props object
84 - var message3 = getPropTypeWarningMessage(propTypes, {}, 'testComponent');
85 - expect(message3).toContain(unspecifiedMsg);
86 -}
87 -
88 -function typeCheckPass(declaration, value) {
89 - const propTypes = {
90 - testProp: declaration,
91 - };
92 - const props = {
93 - testProp: value,
94 - };
95 - const message = getPropTypeWarningMessage(propTypes, props, 'testComponent');
96 - expect(message).toBe(null);
97 -}
98 -
99 -function expectThrowInDevelopment(declaration, value) {
100 - var props = {testProp: value};
101 - var propName = 'testProp' + Math.random().toString();
102 - var componentName = 'testComponent' + Math.random().toString();
103 - var message;
104 - try {
105 - declaration(props, propName, componentName, 'prop');
106 - } catch (e) {
107 - message = e.message;
108 - }
109 - expect(message).toContain(
110 - 'Calling PropTypes validators directly is not supported',
111 - );
112 - console.error.calls.reset();
113 -}
114 -
115 -describe('ReactPropTypes', () => {
116 - beforeEach(() => {
117 - React = require('react');
118 - ReactDOM = require('react-dom');
119 - resetWarningCache();
120 - });
121 -
122 - describe('checkPropTypes', () => {
123 - it('does not return a value from a validator', () => {
124 - spyOn(console, 'error');
125 - const propTypes = {
126 - foo(props, propName, componentName) {
127 - return new Error('some error');
128 - },
129 - };
130 - const props = {foo: 'foo'};
131 - const returnValue = checkPropTypes(
132 - propTypes,
133 - props,
134 - 'prop',
135 - 'testComponent',
136 - null,
137 - );
138 - expect(console.error.calls.argsFor(0)[0]).toContain('some error');
139 - expect(returnValue).toBe(undefined);
140 - });
141 -
142 - it('does not throw if validator throws', () => {
143 - spyOn(console, 'error');
144 - const propTypes = {
145 - foo(props, propName, componentName) {
146 - throw new Error('some error');
147 - },
148 - };
149 - const props = {foo: 'foo'};
150 - const returnValue = checkPropTypes(
151 - propTypes,
152 - props,
153 - 'prop',
154 - 'testComponent',
155 - null,
156 - );
157 - expect(console.error.calls.argsFor(0)[0]).toContain('some error');
158 - expect(returnValue).toBe(undefined);
159 - });
160 - });
161 -
162 - describe('Primitive Types', () => {
163 - it('should warn for invalid strings', () => {
164 - typeCheckFail(
165 - PropTypes.string,
166 - [],
167 - 'Invalid prop `testProp` of type `array` supplied to ' +
168 - '`testComponent`, expected `string`.',
169 - );
170 - typeCheckFail(
171 - PropTypes.string,
172 - false,
173 - 'Invalid prop `testProp` of type `boolean` supplied to ' +
174 - '`testComponent`, expected `string`.',
175 - );
176 - typeCheckFail(
177 - PropTypes.string,
178 - 0,
179 - 'Invalid prop `testProp` of type `number` supplied to ' +
180 - '`testComponent`, expected `string`.',
181 - );
182 - typeCheckFail(
183 - PropTypes.string,
184 - {},
185 - 'Invalid prop `testProp` of type `object` supplied to ' +
186 - '`testComponent`, expected `string`.',
187 - );
188 - typeCheckFail(
189 - PropTypes.string,
190 - Symbol(),
191 - 'Invalid prop `testProp` of type `symbol` supplied to ' +
192 - '`testComponent`, expected `string`.',
193 - );
194 - });
195 -
196 - it('should fail date and regexp correctly', () => {
197 - typeCheckFail(
198 - PropTypes.string,
199 - new Date(),
200 - 'Invalid prop `testProp` of type `date` supplied to ' +
201 - '`testComponent`, expected `string`.',
202 - );
203 - typeCheckFail(
204 - PropTypes.string,
205 - /please/,
206 - 'Invalid prop `testProp` of type `regexp` supplied to ' +
207 - '`testComponent`, expected `string`.',
208 - );
209 - });
210 -
211 - it('should not warn for valid values', () => {
212 - typeCheckPass(PropTypes.array, []);
213 - typeCheckPass(PropTypes.bool, false);
214 - typeCheckPass(PropTypes.func, function() {});
215 - typeCheckPass(PropTypes.number, 0);
216 - typeCheckPass(PropTypes.string, '');
217 - typeCheckPass(PropTypes.object, {});
218 - typeCheckPass(PropTypes.object, new Date());
219 - typeCheckPass(PropTypes.object, /please/);
220 - typeCheckPass(PropTypes.symbol, Symbol());
221 - });
222 -
223 - it('should be implicitly optional and not warn without values', () => {
224 - typeCheckPass(PropTypes.string, null);
225 - typeCheckPass(PropTypes.string, undefined);
226 - });
227 -
228 - it('should warn for missing required values', () => {
229 - typeCheckFailRequiredValues(PropTypes.string.isRequired);
230 - });
231 -
232 - it('should throw if called manually in development', () => {
233 - spyOn(console, 'error');
234 - expectThrowInDevelopment(PropTypes.array, /please/);
235 - expectThrowInDevelopment(PropTypes.array, []);
236 - expectThrowInDevelopment(PropTypes.array.isRequired, /please/);
237 - expectThrowInDevelopment(PropTypes.array.isRequired, []);
238 - expectThrowInDevelopment(PropTypes.array.isRequired, null);
239 - expectThrowInDevelopment(PropTypes.array.isRequired, undefined);
240 - expectThrowInDevelopment(PropTypes.bool, []);
241 - expectThrowInDevelopment(PropTypes.bool, true);
242 - expectThrowInDevelopment(PropTypes.bool.isRequired, []);
243 - expectThrowInDevelopment(PropTypes.bool.isRequired, true);
244 - expectThrowInDevelopment(PropTypes.bool.isRequired, null);
245 - expectThrowInDevelopment(PropTypes.bool.isRequired, undefined);
246 - expectThrowInDevelopment(PropTypes.func, false);
247 - expectThrowInDevelopment(PropTypes.func, function() {});
248 - expectThrowInDevelopment(PropTypes.func.isRequired, false);
249 - expectThrowInDevelopment(PropTypes.func.isRequired, function() {});
250 - expectThrowInDevelopment(PropTypes.func.isRequired, null);
251 - expectThrowInDevelopment(PropTypes.func.isRequired, undefined);
252 - expectThrowInDevelopment(PropTypes.number, function() {});
253 - expectThrowInDevelopment(PropTypes.number, 42);
254 - expectThrowInDevelopment(PropTypes.number.isRequired, function() {});
255 - expectThrowInDevelopment(PropTypes.number.isRequired, 42);
256 - expectThrowInDevelopment(PropTypes.number.isRequired, null);
257 - expectThrowInDevelopment(PropTypes.number.isRequired, undefined);
258 - expectThrowInDevelopment(PropTypes.string, 0);
259 - expectThrowInDevelopment(PropTypes.string, 'foo');
260 - expectThrowInDevelopment(PropTypes.string.isRequired, 0);
261 - expectThrowInDevelopment(PropTypes.string.isRequired, 'foo');
262 - expectThrowInDevelopment(PropTypes.string.isRequired, null);
263 - expectThrowInDevelopment(PropTypes.string.isRequired, undefined);
264 - expectThrowInDevelopment(PropTypes.symbol, 0);
265 - expectThrowInDevelopment(PropTypes.symbol, Symbol('Foo'));
266 - expectThrowInDevelopment(PropTypes.symbol.isRequired, 0);
267 - expectThrowInDevelopment(PropTypes.symbol.isRequired, Symbol('Foo'));
268 - expectThrowInDevelopment(PropTypes.symbol.isRequired, null);
269 - expectThrowInDevelopment(PropTypes.symbol.isRequired, undefined);
270 - expectThrowInDevelopment(PropTypes.object, '');
271 - expectThrowInDevelopment(PropTypes.object, {foo: 'bar'});
272 - expectThrowInDevelopment(PropTypes.object.isRequired, '');
273 - expectThrowInDevelopment(PropTypes.object.isRequired, {foo: 'bar'});
274 - expectThrowInDevelopment(PropTypes.object.isRequired, null);
275 - expectThrowInDevelopment(PropTypes.object.isRequired, undefined);
276 - });
277 - });
278 -
279 - describe('Any type', () => {
280 - it('should should accept any value', () => {
281 - typeCheckPass(PropTypes.any, 0);
282 - typeCheckPass(PropTypes.any, 'str');
283 - typeCheckPass(PropTypes.any, []);
284 - typeCheckPass(PropTypes.any, Symbol());
285 - });
286 -
287 - it('should be implicitly optional and not warn without values', () => {
288 - typeCheckPass(PropTypes.any, null);
289 - typeCheckPass(PropTypes.any, undefined);
290 - });
291 -
292 - it('should warn for missing required values', () => {
293 - typeCheckFailRequiredValues(PropTypes.any.isRequired);
294 - });
295 -
296 - it('should throw if called manually in development', () => {
297 - spyOn(console, 'error');
298 - expectThrowInDevelopment(PropTypes.any, null);
299 - expectThrowInDevelopment(PropTypes.any.isRequired, null);
300 - expectThrowInDevelopment(PropTypes.any.isRequired, undefined);
301 - });
302 - });
303 -
304 - describe('ArrayOf Type', () => {
305 - it('should fail for invalid argument', () => {
306 - typeCheckFail(
307 - PropTypes.arrayOf({foo: PropTypes.string}),
308 - {foo: 'bar'},
309 - 'Property `testProp` of component `testComponent` has invalid PropType notation inside arrayOf.',
310 - );
311 - });
312 -
313 - it('should support the arrayOf propTypes', () => {
314 - typeCheckPass(PropTypes.arrayOf(PropTypes.number), [1, 2, 3]);
315 - typeCheckPass(PropTypes.arrayOf(PropTypes.string), ['a', 'b', 'c']);
316 - typeCheckPass(PropTypes.arrayOf(PropTypes.oneOf(['a', 'b'])), ['a', 'b']);
317 - typeCheckPass(PropTypes.arrayOf(PropTypes.symbol), [Symbol(), Symbol()]);
318 - });
319 -
320 - it('should support arrayOf with complex types', () => {
321 - typeCheckPass(
322 - PropTypes.arrayOf(PropTypes.shape({a: PropTypes.number.isRequired})),
323 - [{a: 1}, {a: 2}],
324 - );
325 -
326 - function Thing() {}
327 - typeCheckPass(PropTypes.arrayOf(PropTypes.instanceOf(Thing)), [
328 - new Thing(),
329 - new Thing(),
330 - ]);
331 - });
332 -
333 - it('should warn with invalid items in the array', () => {
334 - typeCheckFail(
335 - PropTypes.arrayOf(PropTypes.number),
336 - [1, 2, 'b'],
337 - 'Invalid prop `testProp[2]` of type `string` supplied to ' +
338 - '`testComponent`, expected `number`.',
339 - );
340 - });
341 -
342 - it('should warn with invalid complex types', () => {
343 - function Thing() {}
344 - var name = Thing.name || '<<anonymous>>';
345 -
346 - typeCheckFail(
347 - PropTypes.arrayOf(PropTypes.instanceOf(Thing)),
348 - [new Thing(), 'xyz'],
349 - 'Invalid prop `testProp[1]` of type `String` supplied to ' +
350 - '`testComponent`, expected instance of `' +
351 - name +
352 - '`.',
353 - );
354 - });
355 -
356 - it('should warn when passed something other than an array', () => {
357 - typeCheckFail(
358 - PropTypes.arrayOf(PropTypes.number),
359 - {'0': 'maybe-array', length: 1},
360 - 'Invalid prop `testProp` of type `object` supplied to ' +
361 - '`testComponent`, expected an array.',
362 - );
363 - typeCheckFail(
364 - PropTypes.arrayOf(PropTypes.number),
365 - 123,
366 - 'Invalid prop `testProp` of type `number` supplied to ' +
367 - '`testComponent`, expected an array.',
368 - );
369 - typeCheckFail(
370 - PropTypes.arrayOf(PropTypes.number),
371 - 'string',
372 - 'Invalid prop `testProp` of type `string` supplied to ' +
373 - '`testComponent`, expected an array.',
374 - );
375 - });
376 -
377 - it('should not warn when passing an empty array', () => {
378 - typeCheckPass(PropTypes.arrayOf(PropTypes.number), []);
379 - });
380 -
381 - it('should be implicitly optional and not warn without values', () => {
382 - typeCheckPass(PropTypes.arrayOf(PropTypes.number), null);
383 - typeCheckPass(PropTypes.arrayOf(PropTypes.number), undefined);
384 - });
385 -
386 - it('should warn for missing required values', () => {
387 - typeCheckFailRequiredValues(
388 - PropTypes.arrayOf(PropTypes.number).isRequired,
389 - );
390 - });
391 -
392 - it('should throw if called manually in development', () => {
393 - spyOn(console, 'error');
394 - expectThrowInDevelopment(PropTypes.arrayOf({foo: PropTypes.string}), {
395 - foo: 'bar',
396 - });
397 - expectThrowInDevelopment(PropTypes.arrayOf(PropTypes.number), [
398 - 1,
399 - 2,
400 - 'b',
401 - ]);
402 - expectThrowInDevelopment(PropTypes.arrayOf(PropTypes.number), {
403 - '0': 'maybe-array',
404 - length: 1,
405 - });
406 - expectThrowInDevelopment(
407 - PropTypes.arrayOf(PropTypes.number).isRequired,
408 - null,
409 - );
410 - expectThrowInDevelopment(
411 - PropTypes.arrayOf(PropTypes.number).isRequired,
412 - undefined,
413 - );
414 - });
415 - });
416 -
417 - describe('Component Type', () => {
418 - beforeEach(() => {
419 - Component = class extends React.Component {
420 - static propTypes = {
421 - label: PropTypes.element.isRequired,
422 - };
423 -
424 - render() {
425 - return <div>{this.props.label}</div>;
426 - }
427 - };
428 - });
429 -
430 - it('should support components', () => {
431 - typeCheckPass(PropTypes.element, <div />);
432 - });
433 -
434 - it('should not support multiple components or scalar values', () => {
435 - typeCheckFail(
436 - PropTypes.element,
437 - [<div />, <div />],
438 - 'Invalid prop `testProp` of type `array` supplied to `testComponent`, ' +
439 - 'expected a single ReactElement.',
440 - );
441 - typeCheckFail(
442 - PropTypes.element,
443 - 123,
444 - 'Invalid prop `testProp` of type `number` supplied to `testComponent`, ' +
445 - 'expected a single ReactElement.',
446 - );
447 - typeCheckFail(
448 - PropTypes.element,
449 - 'foo',
450 - 'Invalid prop `testProp` of type `string` supplied to `testComponent`, ' +
451 - 'expected a single ReactElement.',
452 - );
453 - typeCheckFail(
454 - PropTypes.element,
455 - false,
456 - 'Invalid prop `testProp` of type `boolean` supplied to `testComponent`, ' +
457 - 'expected a single ReactElement.',
458 - );
459 - });
460 -
461 - it('should be able to define a single child as label', () => {
462 - spyOn(console, 'error');
463 -
464 - var container = document.createElement('div');
465 - ReactDOM.render(<Component label={<div />} />, container);
466 -
467 - expectDev(console.error.calls.count()).toBe(0);
468 - });
469 -
470 - it('should warn when passing no label and isRequired is set', () => {
471 - spyOn(console, 'error');
472 -
473 - var container = document.createElement('div');
474 - ReactDOM.render(<Component />, container);
475 -
476 - expectDev(console.error.calls.count()).toBe(1);
477 - });
478 -
479 - it('should be implicitly optional and not warn without values', () => {
480 - typeCheckPass(PropTypes.element, null);
481 - typeCheckPass(PropTypes.element, undefined);
482 - });
483 -
484 - it('should warn for missing required values', () => {
485 - typeCheckFailRequiredValues(PropTypes.element.isRequired);
486 - });
487 -
488 - it('should throw if called manually in development', () => {
489 - spyOn(console, 'error');
490 - expectThrowInDevelopment(PropTypes.element, [<div />, <div />]);
491 - expectThrowInDevelopment(PropTypes.element, <div />);
492 - expectThrowInDevelopment(PropTypes.element, 123);
493 - expectThrowInDevelopment(PropTypes.element, 'foo');
494 - expectThrowInDevelopment(PropTypes.element, false);
495 - expectThrowInDevelopment(PropTypes.element.isRequired, null);
496 - expectThrowInDevelopment(PropTypes.element.isRequired, undefined);
497 - });
498 - });
499 -
500 - describe('Instance Types', () => {
501 - it('should warn for invalid instances', () => {
502 - function Person() {}
503 - function Cat() {}
504 - var personName = Person.name || '<<anonymous>>';
505 - var dateName = Date.name || '<<anonymous>>';
506 - var regExpName = RegExp.name || '<<anonymous>>';
507 -
508 - typeCheckFail(
509 - PropTypes.instanceOf(Person),
510 - false,
511 - 'Invalid prop `testProp` of type `Boolean` supplied to ' +
512 - '`testComponent`, expected instance of `' +
513 - personName +
514 - '`.',
515 - );
516 - typeCheckFail(
517 - PropTypes.instanceOf(Person),
518 - {},
519 - 'Invalid prop `testProp` of type `Object` supplied to ' +
520 - '`testComponent`, expected instance of `' +
521 - personName +
522 - '`.',
523 - );
524 - typeCheckFail(
525 - PropTypes.instanceOf(Person),
526 - '',
527 - 'Invalid prop `testProp` of type `String` supplied to ' +
528 - '`testComponent`, expected instance of `' +
529 - personName +
530 - '`.',
531 - );
532 - typeCheckFail(
533 - PropTypes.instanceOf(Date),
534 - {},
535 - 'Invalid prop `testProp` of type `Object` supplied to ' +
536 - '`testComponent`, expected instance of `' +
537 - dateName +
538 - '`.',
539 - );
540 - typeCheckFail(
541 - PropTypes.instanceOf(RegExp),
542 - {},
543 - 'Invalid prop `testProp` of type `Object` supplied to ' +
544 - '`testComponent`, expected instance of `' +
545 - regExpName +
546 - '`.',
547 - );
548 - typeCheckFail(
549 - PropTypes.instanceOf(Person),
550 - new Cat(),
551 - 'Invalid prop `testProp` of type `Cat` supplied to ' +
552 - '`testComponent`, expected instance of `' +
553 - personName +
554 - '`.',
555 - );
556 - typeCheckFail(
557 - PropTypes.instanceOf(Person),
558 - Object.create(null),
559 - 'Invalid prop `testProp` of type `<<anonymous>>` supplied to ' +
560 - '`testComponent`, expected instance of `' +
561 - personName +
562 - '`.',
563 - );
564 - });
565 -
566 - it('should not warn for valid values', () => {
567 - function Person() {}
568 - function Engineer() {}
569 - Engineer.prototype = new Person();
570 -
571 - typeCheckPass(PropTypes.instanceOf(Person), new Person());
572 - typeCheckPass(PropTypes.instanceOf(Person), new Engineer());
573 -
574 - typeCheckPass(PropTypes.instanceOf(Date), new Date());
575 - typeCheckPass(PropTypes.instanceOf(RegExp), /please/);
576 - });
577 -
578 - it('should be implicitly optional and not warn without values', () => {
579 - typeCheckPass(PropTypes.instanceOf(String), null);
580 - typeCheckPass(PropTypes.instanceOf(String), undefined);
581 - });
582 -
583 - it('should warn for missing required values', () => {
584 - typeCheckFailRequiredValues(PropTypes.instanceOf(String).isRequired);
585 - });
586 -
587 - it('should throw if called manually in development', () => {
588 - spyOn(console, 'error');
589 - expectThrowInDevelopment(PropTypes.instanceOf(Date), {});
590 - expectThrowInDevelopment(PropTypes.instanceOf(Date), new Date());
591 - expectThrowInDevelopment(PropTypes.instanceOf(Date).isRequired, {});
592 - expectThrowInDevelopment(
593 - PropTypes.instanceOf(Date).isRequired,
594 - new Date(),
595 - );
596 - });
597 - });
598 -
599 - describe('React Component Types', () => {
600 - beforeEach(() => {
601 - MyComponent = class extends React.Component {
602 - render() {
603 - return <div />;
604 - }
605 - };
606 - });
607 -
608 - it('should warn for invalid values', () => {
609 - var failMessage =
610 - 'Invalid prop `testProp` supplied to ' +
611 - '`testComponent`, expected a ReactNode.';
612 - typeCheckFail(PropTypes.node, true, failMessage);
613 - typeCheckFail(PropTypes.node, function() {}, failMessage);
614 - typeCheckFail(PropTypes.node, {key: function() {}}, failMessage);
615 - typeCheckFail(PropTypes.node, {key: <div />}, failMessage);
616 - });
617 -
618 - it('should not warn for valid values', () => {
619 - typeCheckPass(PropTypes.node, <div />);
620 - typeCheckPass(PropTypes.node, false);
621 - typeCheckPass(PropTypes.node, <MyComponent />);
622 - typeCheckPass(PropTypes.node, 'Some string');
623 - typeCheckPass(PropTypes.node, []);
624 - typeCheckPass(PropTypes.node, [
625 - 123,
626 - 'Some string',
627 - <div />,
628 - ['Another string', [456], <span />, <MyComponent />],
629 - <MyComponent />,
630 - null,
631 - undefined,
632 - ]);
633 - });
634 -
635 - it('should not warn for iterables', () => {
636 - var iterable = {
637 - '@@iterator': function() {
638 - var i = 0;
639 - return {
640 - next: function() {
641 - var done = ++i > 2;
642 - return {value: done ? undefined : <MyComponent />, done: done};
643 - },
644 - };
645 - },
646 - };
647 -
648 - typeCheckPass(PropTypes.node, iterable);
649 - });
650 -
651 - it('should not warn for entry iterables', () => {
652 - var iterable = {
653 - '@@iterator': function() {
654 - var i = 0;
655 - return {
656 - next: function() {
657 - var done = ++i > 2;
658 - return {
659 - value: done ? undefined : ['#' + i, <MyComponent />],
660 - done: done,
661 - };
662 - },
663 - };
664 - },
665 - };
666 - iterable.entries = iterable['@@iterator'];
667 -
668 - typeCheckPass(PropTypes.node, iterable);
669 - });
670 -
671 - it('should not warn for null/undefined if not required', () => {
672 - typeCheckPass(PropTypes.node, null);
673 - typeCheckPass(PropTypes.node, undefined);
674 - });
675 -
676 - it('should warn for missing required values', () => {
677 - typeCheckFailRequiredValues(PropTypes.node.isRequired);
678 - });
679 -
680 - it('should accept empty array for required props', () => {
681 - typeCheckPass(PropTypes.node.isRequired, []);
682 - });
683 -
684 - it('should throw if called manually in development', () => {
685 - spyOn(console, 'error');
686 - expectThrowInDevelopment(PropTypes.node, 'node');
687 - expectThrowInDevelopment(PropTypes.node, {});
688 - expectThrowInDevelopment(PropTypes.node.isRequired, 'node');
689 - expectThrowInDevelopment(PropTypes.node.isRequired, undefined);
690 - expectThrowInDevelopment(PropTypes.node.isRequired, undefined);
691 - });
692 - });
693 -
694 - describe('ObjectOf Type', () => {
695 - it('should fail for invalid argument', () => {
696 - typeCheckFail(
697 - PropTypes.objectOf({foo: PropTypes.string}),
698 - {foo: 'bar'},
699 - 'Property `testProp` of component `testComponent` has invalid PropType notation inside objectOf.',
700 - );
701 - });
702 -
703 - it('should support the objectOf propTypes', () => {
704 - typeCheckPass(PropTypes.objectOf(PropTypes.number), {a: 1, b: 2, c: 3});
705 - typeCheckPass(PropTypes.objectOf(PropTypes.string), {
706 - a: 'a',
707 - b: 'b',
708 - c: 'c',
709 - });
710 - typeCheckPass(PropTypes.objectOf(PropTypes.oneOf(['a', 'b'])), {
711 - a: 'a',
712 - b: 'b',
713 - });
714 - typeCheckPass(PropTypes.objectOf(PropTypes.symbol), {
715 - a: Symbol(),
716 - b: Symbol(),
717 - c: Symbol(),
718 - });
719 - });
720 -
721 - it('should support objectOf with complex types', () => {
722 - typeCheckPass(
723 - PropTypes.objectOf(PropTypes.shape({a: PropTypes.number.isRequired})),
724 - {a: {a: 1}, b: {a: 2}},
725 - );
726 -
727 - function Thing() {}
728 - typeCheckPass(PropTypes.objectOf(PropTypes.instanceOf(Thing)), {
729 - a: new Thing(),
730 - b: new Thing(),
731 - });
732 - });
733 -
734 - it('should warn with invalid items in the object', () => {
735 - typeCheckFail(
736 - PropTypes.objectOf(PropTypes.number),
737 - {a: 1, b: 2, c: 'b'},
738 - 'Invalid prop `testProp.c` of type `string` supplied to `testComponent`, ' +
739 - 'expected `number`.',
740 - );
741 - });
742 -
743 - it('should warn with invalid complex types', () => {
744 - function Thing() {}
745 - var name = Thing.name || '<<anonymous>>';
746 -
747 - typeCheckFail(
748 - PropTypes.objectOf(PropTypes.instanceOf(Thing)),
749 - {a: new Thing(), b: 'xyz'},
750 - 'Invalid prop `testProp.b` of type `String` supplied to ' +
751 - '`testComponent`, expected instance of `' +
752 - name +
753 - '`.',
754 - );
755 - });
756 -
757 - it('should warn when passed something other than an object', () => {
758 - typeCheckFail(
759 - PropTypes.objectOf(PropTypes.number),
760 - [1, 2],
761 - 'Invalid prop `testProp` of type `array` supplied to ' +
762 - '`testComponent`, expected an object.',
763 - );
764 - typeCheckFail(
765 - PropTypes.objectOf(PropTypes.number),
766 - 123,
767 - 'Invalid prop `testProp` of type `number` supplied to ' +
768 - '`testComponent`, expected an object.',
769 - );
770 - typeCheckFail(
771 - PropTypes.objectOf(PropTypes.number),
772 - 'string',
773 - 'Invalid prop `testProp` of type `string` supplied to ' +
774 - '`testComponent`, expected an object.',
775 - );
776 - typeCheckFail(
777 - PropTypes.objectOf(PropTypes.symbol),
778 - Symbol(),
779 - 'Invalid prop `testProp` of type `symbol` supplied to ' +
780 - '`testComponent`, expected an object.',
781 - );
782 - });
783 -
784 - it('should not warn when passing an empty object', () => {
785 - typeCheckPass(PropTypes.objectOf(PropTypes.number), {});
786 - });
787 -
788 - it('should be implicitly optional and not warn without values', () => {
789 - typeCheckPass(PropTypes.objectOf(PropTypes.number), null);
790 - typeCheckPass(PropTypes.objectOf(PropTypes.number), undefined);
791 - });
792 -
793 - it('should warn for missing required values', () => {
794 - typeCheckFailRequiredValues(
795 - PropTypes.objectOf(PropTypes.number).isRequired,
796 - );
797 - });
798 -
799 - it('should throw if called manually in development', () => {
800 - spyOn(console, 'error');
801 - expectThrowInDevelopment(PropTypes.objectOf({foo: PropTypes.string}), {
802 - foo: 'bar',
803 - });
804 - expectThrowInDevelopment(PropTypes.objectOf(PropTypes.number), {
805 - a: 1,
806 - b: 2,
807 - c: 'b',
808 - });
809 - expectThrowInDevelopment(PropTypes.objectOf(PropTypes.number), [1, 2]);
810 - expectThrowInDevelopment(PropTypes.objectOf(PropTypes.number), null);
811 - expectThrowInDevelopment(PropTypes.objectOf(PropTypes.number), undefined);
812 - });
813 - });
814 -
815 - describe('OneOf Types', () => {
816 - it('should warn but not error for invalid argument', () => {
817 - spyOn(console, 'error');
818 -
819 - PropTypes.oneOf('red', 'blue');
820 -
821 - expectDev(console.error).toHaveBeenCalled();
822 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
823 - 'Invalid argument supplied to oneOf, expected an instance of array.',
824 - );
825 -
826 - typeCheckPass(PropTypes.oneOf('red', 'blue'), 'red');
827 - });
828 -
829 - it('should warn for invalid values', () => {
830 - typeCheckFail(
831 - PropTypes.oneOf(['red', 'blue']),
832 - true,
833 - 'Invalid prop `testProp` of value `true` supplied to ' +
834 - '`testComponent`, expected one of ["red","blue"].',
835 - );
836 - typeCheckFail(
837 - PropTypes.oneOf(['red', 'blue']),
838 - [],
839 - 'Invalid prop `testProp` of value `` supplied to `testComponent`, ' +
840 - 'expected one of ["red","blue"].',
841 - );
842 - typeCheckFail(
843 - PropTypes.oneOf(['red', 'blue']),
844 - '',
845 - 'Invalid prop `testProp` of value `` supplied to `testComponent`, ' +
846 - 'expected one of ["red","blue"].',
847 - );
848 - typeCheckFail(
849 - PropTypes.oneOf([0, 'false']),
850 - false,
851 - 'Invalid prop `testProp` of value `false` supplied to ' +
852 - '`testComponent`, expected one of [0,"false"].',
853 - );
854 - });
855 -
856 - it('should not warn for valid values', () => {
857 - typeCheckPass(PropTypes.oneOf(['red', 'blue']), 'red');
858 - typeCheckPass(PropTypes.oneOf(['red', 'blue']), 'blue');
859 - typeCheckPass(PropTypes.oneOf(['red', 'blue', NaN]), NaN);
860 - });
861 -
862 - it('should be implicitly optional and not warn without values', () => {
863 - typeCheckPass(PropTypes.oneOf(['red', 'blue']), null);
864 - typeCheckPass(PropTypes.oneOf(['red', 'blue']), undefined);
865 - });
866 -
867 - it('should warn for missing required values', () => {
868 - typeCheckFailRequiredValues(PropTypes.oneOf(['red', 'blue']).isRequired);
869 - });
870 -
871 - it('should throw if called manually in development', () => {
872 - spyOn(console, 'error');
873 - expectThrowInDevelopment(PropTypes.oneOf(['red', 'blue']), true);
874 - expectThrowInDevelopment(PropTypes.oneOf(['red', 'blue']), null);
875 - expectThrowInDevelopment(PropTypes.oneOf(['red', 'blue']), undefined);
876 - });
877 - });
878 -
879 - describe('Union Types', () => {
880 - it('should warn but not error for invalid argument', () => {
881 - spyOn(console, 'error');
882 -
883 - PropTypes.oneOfType(PropTypes.string, PropTypes.number);
884 -
885 - expectDev(console.error).toHaveBeenCalled();
886 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
887 - 'Invalid argument supplied to oneOfType, expected an instance of array.',
888 - );
889 -
890 - typeCheckPass(PropTypes.oneOf(PropTypes.string, PropTypes.number), []);
891 - });
892 -
893 - it('should warn if none of the types are valid', () => {
894 - typeCheckFail(
895 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
896 - [],
897 - 'Invalid prop `testProp` supplied to `testComponent`.',
898 - );
899 -
900 - var checker = PropTypes.oneOfType([
901 - PropTypes.shape({a: PropTypes.number.isRequired}),
902 - PropTypes.shape({b: PropTypes.number.isRequired}),
903 - ]);
904 - typeCheckFail(
905 - checker,
906 - {c: 1},
907 - 'Invalid prop `testProp` supplied to `testComponent`.',
908 - );
909 - });
910 -
911 - it('should not warn if one of the types are valid', () => {
912 - var checker = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
913 - typeCheckPass(checker, null);
914 - typeCheckPass(checker, 'foo');
915 - typeCheckPass(checker, 123);
916 -
917 - checker = PropTypes.oneOfType([
918 - PropTypes.shape({a: PropTypes.number.isRequired}),
919 - PropTypes.shape({b: PropTypes.number.isRequired}),
920 - ]);
921 - typeCheckPass(checker, {a: 1});
922 - typeCheckPass(checker, {b: 1});
923 - });
924 -
925 - it('should be implicitly optional and not warn without values', () => {
926 - typeCheckPass(
927 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
928 - null,
929 - );
930 - typeCheckPass(
931 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
932 - undefined,
933 - );
934 - });
935 -
936 - it('should warn for missing required values', () => {
937 - typeCheckFailRequiredValues(
938 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
939 - );
940 - });
941 -
942 - it('should throw if called manually in development', () => {
943 - spyOn(console, 'error');
944 - expectThrowInDevelopment(
945 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
946 - [],
947 - );
948 - expectThrowInDevelopment(
949 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
950 - null,
951 - );
952 - expectThrowInDevelopment(
953 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
954 - undefined,
955 - );
956 - });
957 - });
958 -
959 - describe('Shape Types', () => {
960 - it('should warn for non objects', () => {
961 - typeCheckFail(
962 - PropTypes.shape({}),
963 - 'some string',
964 - 'Invalid prop `testProp` of type `string` supplied to ' +
965 - '`testComponent`, expected `object`.',
966 - );
967 - typeCheckFail(
968 - PropTypes.shape({}),
969 - ['array'],
970 - 'Invalid prop `testProp` of type `array` supplied to ' +
971 - '`testComponent`, expected `object`.',
972 - );
973 - });
974 -
975 - it('should not warn for empty values', () => {
976 - typeCheckPass(PropTypes.shape({}), undefined);
977 - typeCheckPass(PropTypes.shape({}), null);
978 - typeCheckPass(PropTypes.shape({}), {});
979 - });
980 -
981 - it('should not warn for an empty object', () => {
982 - typeCheckPass(PropTypes.shape({}).isRequired, {});
983 - });
984 -
985 - it('should not warn for non specified types', () => {
986 - typeCheckPass(PropTypes.shape({}), {key: 1});
987 - });
988 -
989 - it('should not warn for valid types', () => {
990 - typeCheckPass(PropTypes.shape({key: PropTypes.number}), {key: 1});
991 - });
992 -
993 - it('should warn for required valid types', () => {
994 - typeCheckFail(
995 - PropTypes.shape({key: PropTypes.number.isRequired}),
996 - {},
997 - 'The prop `testProp.key` is marked as required in `testComponent`, ' +
998 - 'but its value is `undefined`.',
999 - );
1000 - });
1001 -
1002 - it('should warn for the first required type', () => {
1003 - typeCheckFail(
1004 - PropTypes.shape({
1005 - key: PropTypes.number.isRequired,
1006 - secondKey: PropTypes.number.isRequired,
1007 - }),
1008 - {},
1009 - 'The prop `testProp.key` is marked as required in `testComponent`, ' +
1010 - 'but its value is `undefined`.',
1011 - );
1012 - });
1013 -
1014 - it('should warn for invalid key types', () => {
1015 - typeCheckFail(
1016 - PropTypes.shape({key: PropTypes.number}),
1017 - {key: 'abc'},
1018 - 'Invalid prop `testProp.key` of type `string` supplied to `testComponent`, ' +
1019 - 'expected `number`.',
1020 - );
1021 - });
1022 -
1023 - it('should be implicitly optional and not warn without values', () => {
1024 - typeCheckPass(
1025 - PropTypes.shape(PropTypes.shape({key: PropTypes.number})),
1026 - null,
1027 - );
1028 - typeCheckPass(
1029 - PropTypes.shape(PropTypes.shape({key: PropTypes.number})),
1030 - undefined,
1031 - );
1032 - });
1033 -
1034 - it('should warn for missing required values', () => {
1035 - typeCheckFailRequiredValues(
1036 - PropTypes.shape({key: PropTypes.number}).isRequired,
1037 - );
1038 - });
1039 -
1040 - it('should throw if called manually in development', () => {
1041 - spyOn(console, 'error');
1042 - expectThrowInDevelopment(PropTypes.shape({}), 'some string');
1043 - expectThrowInDevelopment(PropTypes.shape({foo: PropTypes.number}), {
1044 - foo: 42,
1045 - });
1046 - expectThrowInDevelopment(
1047 - PropTypes.shape({key: PropTypes.number}).isRequired,
1048 - null,
1049 - );
1050 - expectThrowInDevelopment(
1051 - PropTypes.shape({key: PropTypes.number}).isRequired,
1052 - undefined,
1053 - );
1054 - expectThrowInDevelopment(PropTypes.element, <div />);
1055 - });
1056 - });
1057 -
1058 - describe('Symbol Type', () => {
1059 - it('should warn for non-symbol', () => {
1060 - typeCheckFail(
1061 - PropTypes.symbol,
1062 - 'hello',
1063 - 'Invalid prop `testProp` of type `string` supplied to ' +
1064 - '`testComponent`, expected `symbol`.',
1065 - );
1066 - typeCheckFail(
1067 - PropTypes.symbol,
1068 - function() {},
1069 - 'Invalid prop `testProp` of type `function` supplied to ' +
1070 - '`testComponent`, expected `symbol`.',
1071 - );
1072 - typeCheckFail(
1073 - PropTypes.symbol,
1074 - {
1075 - '@@toStringTag': 'Katana',
1076 - },
1077 - 'Invalid prop `testProp` of type `object` supplied to ' +
1078 - '`testComponent`, expected `symbol`.',
1079 - );
1080 - });
1081 -
1082 - it('should not warn for a polyfilled Symbol', () => {
1083 - var CoreSymbol = require('core-js/library/es6/symbol');
1084 - typeCheckPass(PropTypes.symbol, CoreSymbol('core-js'));
1085 - });
1086 - });
1087 -
1088 - describe('Custom validator', () => {
1089 - beforeEach(() => {
1090 - jest.resetModules();
1091 - });
1092 -
1093 - it('should have been called with the right params', () => {
1094 - var spy = jasmine.createSpy();
1095 - Component = class extends React.Component {
1096 - static propTypes = {num: spy};
1097 -
1098 - render() {
1099 - return <div />;
1100 - }
1101 - };
1102 -
1103 - var container = document.createElement('div');
1104 - ReactDOM.render(<Component num={5} />, container);
1105 -
1106 - expect(spy.calls.count()).toBe(1);
1107 - expect(spy.calls.argsFor(0)[1]).toBe('num');
1108 - });
1109 -
1110 - it('should have been called even if the prop is not present', () => {
1111 - var spy = jasmine.createSpy();
1112 - Component = class extends React.Component {
1113 - static propTypes = {num: spy};
1114 -
1115 - render() {
1116 - return <div />;
1117 - }
1118 - };
1119 -
1120 - var container = document.createElement('div');
1121 - ReactDOM.render(<Component bla={5} />, container);
1122 -
1123 - expect(spy.calls.count()).toBe(1);
1124 - expect(spy.calls.argsFor(0)[1]).toBe('num');
1125 - });
1126 -
1127 - it("should have received the validator's return value", () => {
1128 - spyOn(console, 'error');
1129 - var spy = jasmine
1130 - .createSpy()
1131 - .and.callFake(function(props, propName, componentName) {
1132 - if (props[propName] !== 5) {
1133 - return new Error('num must be 5!');
1134 - }
1135 - });
1136 - Component = class extends React.Component {
1137 - static propTypes = {num: spy};
1138 -
1139 - render() {
1140 - return <div />;
1141 - }
1142 - };
1143 -
1144 - var container = document.createElement('div');
1145 - ReactDOM.render(<Component num={6} />, container);
1146 - expectDev(console.error.calls.count()).toBe(1);
1147 - expect(
1148 - console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)'),
1149 - ).toBe(
1150 - 'Warning: Failed prop type: num must be 5!\n' +
1151 - ' in Component (at **)',
1152 - );
1153 - });
1154 -
1155 - it('should not warn if the validator returned null', () => {
1156 - spyOn(console, 'error');
1157 - var spy = jasmine
1158 - .createSpy()
1159 - .and.callFake(function(props, propName, componentName) {
1160 - return null;
1161 - });
1162 - Component = class extends React.Component {
1163 - static propTypes = {num: spy};
1164 -
1165 - render() {
1166 - return <div />;
1167 - }
1168 - };
1169 -
1170 - var container = document.createElement('div');
1171 - ReactDOM.render(<Component num={5} />, container);
1172 - expectDev(console.error.calls.count()).toBe(0);
1173 - });
1174 - });
1175 -});
src/renderers/__tests__/ReactCompositeComponent-test.js
+28 -28
@@ -17,8 +17,8 @@ var React;
17 var ReactDOM;
18 var ReactDOMServer;
19 var ReactCurrentOwner;
20 -var ReactPropTypes;
20 var ReactTestUtils;
21 +var PropTypes;
22 var shallowEqual;
23 var shallowCompare;
24
@@ -29,8 +29,8 @@ describe('ReactCompositeComponent', () => {
29 ReactDOM = require('react-dom');
30 ReactDOMServer = require('react-dom/server');
31 ReactCurrentOwner = require('ReactCurrentOwner');
32 - ReactPropTypes = require('ReactPropTypes');
32 ReactTestUtils = require('ReactTestUtils');
33 + PropTypes = require('prop-types');
34 shallowEqual = require('fbjs/lib/shallowEqual');
35
36 shallowCompare = function(instance, nextProps, nextState) {
@@ -518,7 +518,7 @@ describe('ReactCompositeComponent', () => {
518
519 class Child extends React.Component {
520 static childContextTypes = {
521 - foo: ReactPropTypes.string,
521 + foo: PropTypes.string,
522 };
523
524 getChildContext() {
@@ -534,7 +534,7 @@ describe('ReactCompositeComponent', () => {
534
535 class Grandchild extends React.Component {
536 static contextTypes = {
537 - foo: ReactPropTypes.string,
537 + foo: PropTypes.string,
538 };
539
540 render() {
@@ -576,8 +576,8 @@ describe('ReactCompositeComponent', () => {
576
577 class Parent extends React.Component {
578 static childContextTypes = {
579 - foo: ReactPropTypes.string,
580 - flag: ReactPropTypes.bool,
579 + foo: PropTypes.string,
580 + flag: PropTypes.bool,
581 };
582
583 state = {
@@ -604,8 +604,8 @@ describe('ReactCompositeComponent', () => {
604
605 class Child extends React.Component {
606 static contextTypes = {
607 - foo: ReactPropTypes.string,
608 - flag: ReactPropTypes.bool,
607 + foo: PropTypes.string,
608 + flag: PropTypes.bool,
609 };
610
611 render() {
@@ -629,7 +629,7 @@ describe('ReactCompositeComponent', () => {
629 it('should pass context when re-rendered for static child within a composite component', () => {
630 class Parent extends React.Component {
631 static childContextTypes = {
632 - flag: ReactPropTypes.bool,
632 + flag: PropTypes.bool,
633 };
634
635 state = {
@@ -649,7 +649,7 @@ describe('ReactCompositeComponent', () => {
649
650 class Child extends React.Component {
651 static contextTypes = {
652 - flag: ReactPropTypes.bool,
652 + flag: PropTypes.bool,
653 };
654
655 render() {
@@ -685,8 +685,8 @@ describe('ReactCompositeComponent', () => {
685
686 class Parent extends React.Component {
687 static childContextTypes = {
688 - foo: ReactPropTypes.string,
689 - depth: ReactPropTypes.number,
688 + foo: PropTypes.string,
689 + depth: PropTypes.number,
690 };
691
692 getChildContext() {
@@ -703,12 +703,12 @@ describe('ReactCompositeComponent', () => {
703
704 class Child extends React.Component {
705 static contextTypes = {
706 - foo: ReactPropTypes.string,
707 - depth: ReactPropTypes.number,
706 + foo: PropTypes.string,
707 + depth: PropTypes.number,
708 };
709
710 static childContextTypes = {
711 - depth: ReactPropTypes.number,
711 + depth: PropTypes.number,
712 };
713
714 getChildContext() {
@@ -725,8 +725,8 @@ describe('ReactCompositeComponent', () => {
725
726 class Grandchild extends React.Component {
727 static contextTypes = {
728 - foo: ReactPropTypes.string,
729 - depth: ReactPropTypes.number,
728 + foo: PropTypes.string,
729 + depth: PropTypes.number,
730 };
731
732 render() {
@@ -746,8 +746,8 @@ describe('ReactCompositeComponent', () => {
746
747 class Parent extends React.Component {
748 static childContextTypes = {
749 - foo: ReactPropTypes.string,
750 - depth: ReactPropTypes.number,
749 + foo: PropTypes.string,
750 + depth: PropTypes.number,
751 };
752
753 state = {
@@ -772,8 +772,8 @@ describe('ReactCompositeComponent', () => {
772
773 class Child extends React.Component {
774 static contextTypes = {
775 - foo: ReactPropTypes.string,
776 - depth: ReactPropTypes.number,
775 + foo: PropTypes.string,
776 + depth: PropTypes.number,
777 };
778
779 render() {
@@ -797,7 +797,7 @@ describe('ReactCompositeComponent', () => {
797 it('unmasked context propagates through updates', () => {
798 class Leaf extends React.Component {
799 static contextTypes = {
800 - foo: ReactPropTypes.string.isRequired,
800 + foo: PropTypes.string.isRequired,
801 };
802
803 componentWillReceiveProps(nextProps, nextContext) {
@@ -831,7 +831,7 @@ describe('ReactCompositeComponent', () => {
831
832 class Parent extends React.Component {
833 static childContextTypes = {
834 - foo: ReactPropTypes.string,
834 + foo: PropTypes.string,
835 };
836
837 getChildContext() {
@@ -863,7 +863,7 @@ describe('ReactCompositeComponent', () => {
863
864 class GrandChild extends React.Component {
865 static contextTypes = {
866 - foo: ReactPropTypes.string.isRequired,
866 + foo: PropTypes.string.isRequired,
867 };
868
869 componentWillReceiveProps(nextProps, nextContext) {
@@ -885,7 +885,7 @@ describe('ReactCompositeComponent', () => {
885
886 class ChildWithContext extends React.Component {
887 static contextTypes = {
888 - foo: ReactPropTypes.string.isRequired,
888 + foo: PropTypes.string.isRequired,
889 };
890
891 componentWillReceiveProps(nextProps, nextContext) {
@@ -925,7 +925,7 @@ describe('ReactCompositeComponent', () => {
925
926 class Parent extends React.Component {
927 static childContextTypes = {
928 - foo: ReactPropTypes.string,
928 + foo: PropTypes.string,
929 };
930
931 state = {
@@ -1126,7 +1126,7 @@ describe('ReactCompositeComponent', () => {
1126 it('context should be passed down from the parent', () => {
1127 class Parent extends React.Component {
1128 static childContextTypes = {
1129 - foo: ReactPropTypes.string,
1129 + foo: PropTypes.string,
1130 };
1131
1132 getChildContext() {
@@ -1142,7 +1142,7 @@ describe('ReactCompositeComponent', () => {
1142
1143 class Component extends React.Component {
1144 static contextTypes = {
1145 - foo: ReactPropTypes.string.isRequired,
1145 + foo: PropTypes.string.isRequired,
1146 };
1147
1148 render() {