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

createClass + PropTypes + checkPropTypes warnings (#9399)

(Temporarily) re-adds getters with deprecation warnings for React.PropTypes, React.checkPropTypes, and React.createClass. * 08bd020: Replace all references to React.PropTypes with prop-types to avoid triggering our own warning message. * ef5b5c6: Removed several references to React.createClass that appeared after rebasing this branch. (reviewed by @flarnie) * 524ce20: Added getters for createClass and PropTypes to the main React isomorphic object, behind one-time warning messages. (reviewed by @spicyj) * db48f54: Fixed Rollup bundles to inline 'prop-types' and 'create-react-class' for UMD builds only. (reviewed by @spicyj, @trueadm ) * cf49cfd: Updated tests-passing.txt to remove tests that were deleted in this branch. * d34109a: Responses to PR feedback from @spicyj. (Added package.json dependencies to packages/react and packages/react-dom. Renamed a var. Expanded on an inline comment.) * 488c8d2: Added warning for moved package to React.checkPropTypes accessor too and updated build script. * 83bcb29: Wordsmithing for deprecation notices (added fb.me links). * afdc9d2: Tweaked legacy module inlining to remove order-of-deps constraint * d1348b9: Removed $FlowFixMe. * 7dbc3e7: More wordsmithing of deprecation notices based on Dan's feedback.

Brian Vaughn committed Apr 11, 2017 at 14:28 UTC 2beec2f308e27dbe902a8d68e1fc9f3d70ee9372
59 files changed +734 -1397
fixtures/art/VectorWidget.js
+17 -19
@@ -24,13 +24,11 @@ var BASE_VEL = 0.15;
24 /**
25 * An animated SVG component.
26 */
27 -var VectorWidget = React.createClass({
27 +class VectorWidget extends React.Component {
28 /**
29 * Initialize state members.
30 */
31 - getInitialState: function() {
32 - return {degrees: 0, velocity: 0, drag: MOUSE_UP_DRAG};
33 - },
31 + state = {degrees: 0, velocity: 0, drag: MOUSE_UP_DRAG};
32
33 /**
34 * When the component is mounted into the document - this is similar to a
@@ -39,40 +37,40 @@ var VectorWidget = React.createClass({
37 * method. Binding of `this.onTick` is not needed because all React methods
38 * are automatically bound before being mounted.
39 */
42 - componentDidMount: function() {
40 + componentDidMount() {
41 this._interval = window.setInterval(this.onTick, 20);
44 - },
42 + }
43
46 - componentWillUnmount: function() {
44 + componentWillUnmount() {
45 window.clearInterval(this._interval);
48 - },
46 + }
47
50 - onTick: function() {
48 + onTick = () => {
49 var nextDegrees = this.state.degrees + BASE_VEL + this.state.velocity;
50 var nextVelocity = this.state.velocity * this.state.drag;
51 this.setState({degrees: nextDegrees, velocity: nextVelocity});
54 - },
52 + };
53
54 /**
55 * When mousing down, we increase the friction down the velocity.
56 */
59 - handleMouseDown: function() {
57 + handleMouseDown = () => {
58 this.setState({drag: MOUSE_DOWN_DRAG});
61 - },
59 + };
60
61 /**
62 * Cause the rotation to "spring".
63 */
66 - handleMouseUp: function() {
64 + handleMouseUp = () => {
65 var nextVelocity = Math.min(this.state.velocity + CLICK_ACCEL, MAX_VEL);
66 this.setState({velocity: nextVelocity, drag: MOUSE_UP_DRAG});
69 - },
67 + };
68
69 /**
70 * This is the "main" method for any component. The React API allows you to
71 * describe the structure of your UI component at *any* point in time.
72 */
75 - render: function() {
73 + render() {
74 return (
75 <Surface
76 width={700}
@@ -81,12 +79,12 @@ var VectorWidget = React.createClass({
79 {this.renderGraphic(this.state.degrees)}
80 </Surface>
81 );
84 - },
82 + }
83
84 /**
85 * Better SVG support for React coming soon.
86 */
89 - renderGraphic: function(rotation) {
87 + renderGraphic = (rotation) => {
88
89 return (
90 <Group
@@ -112,8 +110,8 @@ var VectorWidget = React.createClass({
110 </Group>
111 </Group>
112 );
115 - }
116 -});
113 + };
114 +}
115
116 var BORDER_PATH = "M3.00191459,4 C1.34400294,4 0,5.34785514 0,7.00550479 L0,220.994495 C0,222.65439 1.34239483,224 3.00191459,224 L276.998085,224 C278.655997,224 280,222.652145 280,220.994495 L280,7.00550479 C280,5.34561033 278.657605,4 276.998085,4 L3.00191459,4 Z M3.00191459,4";
117 var BG_PATH = "M3.00191459,1 C1.34400294,1 0,2.34785514 0,4.00550479 L0,217.994495 C0,219.65439 1.34239483,221 3.00191459,221 L276.998085,221 C278.655997,221 280,219.652145 280,217.994495 L280,4.00550479 C280,2.34561033 278.657605,1 276.998085,1 L3.00191459,1 Z M3.00191459,1";
fixtures/dom/package.json
+1
@@ -8,6 +8,7 @@
8 "dependencies": {
9 "classnames": "^2.2.5",
10 "query-string": "^4.2.3",
11 + "prop-types": "^15.5.6",
12 "react": "^15.4.1",
13 "react-dom": "^15.4.1",
14 "semver": "^5.3.0"
fixtures/dom/public/index.html
+1
@@ -14,6 +14,7 @@
14 Learn how to configure a non-root public URL by running `npm run build`.
15 -->
16 <title>React App</title>
17 + <script src="https://unpkg.com/prop-types@15.5.6/prop-types.js"></script>
18 <script src="react-loader.js"></script>
19 </head>
20 <body>
fixtures/dom/src/components/App.js
+9 -11
@@ -4,17 +4,15 @@ import Fixtures from './fixtures';
4
5 import '../style.css';
6
7 -const App = React.createClass({
8 - render() {
9 - return (
10 - <div>
11 - <Header />
12 - <div className="container" >
13 - <Fixtures />
14 - </div>
7 +function App () {
8 + return (
9 + <div>
10 + <Header />
11 + <div className="container" >
12 + <Fixtures />
13 </div>
16 - );
17 - },
18 -});
14 + </div>
15 + );
16 +}
17
18 export default App;
fixtures/dom/src/components/Fixture.js
+2 -1
@@ -1,7 +1,8 @@
1 +const PropTypes = window.PropTypes;
2 const React = window.React;
3
4 const propTypes = {
4 - children: React.PropTypes.node.isRequired,
5 + children: PropTypes.node.isRequired,
6 };
7
8 class Fixture extends React.Component {
fixtures/dom/src/components/FixtureSet.js
+3 -2
@@ -1,8 +1,9 @@
1 import React from 'react';
2 +import PropTypes from 'prop-types';
3
4 const propTypes = {
4 - title: React.PropTypes.node.isRequired,
5 - description: React.PropTypes.node.isRequired,
5 + title: PropTypes.node.isRequired,
6 + description: PropTypes.node.isRequired,
7 };
8
9 class FixtureSet extends React.Component {
fixtures/dom/src/components/Header.js
+10 -9
@@ -2,13 +2,14 @@ import { parse, stringify } from 'query-string';
2 import getVersionTags from '../tags';
3 const React = window.React;
4
5 -const Header = React.createClass({
6 - getInitialState() {
5 +class Header extends React.Component {
6 + constructor(props, context) {
7 + super(props, context);
8 const query = parse(window.location.search);
9 const version = query.version || 'local';
10 const versions = [version];
10 - return { version, versions };
11 - },
11 + this.state = { version, versions };
12 + }
13 componentWillMount() {
14 getVersionTags()
15 .then(tags => {
@@ -16,7 +17,7 @@ const Header = React.createClass({
17 versions = [`local`, ...versions];
18 this.setState({ versions });
19 })
19 - },
20 + }
21 handleVersionChange(event) {
22 const query = parse(window.location.search);
23 query.version = event.target.value;
@@ -24,10 +25,10 @@ const Header = React.createClass({
25 delete query.version;
26 }
27 window.location.search = stringify(query);
27 - },
28 + }
29 handleFixtureChange(event) {
30 window.location.pathname = event.target.value;
30 - },
31 + }
32 render() {
33 return (
34 <header className="header">
@@ -66,7 +67,7 @@ const Header = React.createClass({
67 </div>
68 </header>
69 );
69 - },
70 -});
70 + }
71 +}
72
73 export default Header;
fixtures/dom/src/components/TestCase.js
+5 -4
@@ -1,14 +1,15 @@
1 import cn from 'classnames';
2 import semver from 'semver';
3 import React from 'react';
4 +import PropTypes from 'prop-types';
5 import { parse } from 'query-string';
5 -import { semverString } from './propTypes'
6 +import { semverString } from './propTypes';
7
8 const propTypes = {
8 - children: React.PropTypes.node.isRequired,
9 - title: React.PropTypes.node.isRequired,
9 + children: PropTypes.node.isRequired,
10 + title: PropTypes.node.isRequired,
11 resolvedIn: semverString,
11 - resolvedBy: React.PropTypes.string
12 + resolvedBy: PropTypes.string
13 };
14
15 class TestCase extends React.Component {
fixtures/dom/src/components/fixtures/buttons/index.js
+1 -1
@@ -10,7 +10,7 @@ function onButtonClick() {
10 export default class ButtonTestCases extends React.Component {
11 render() {
12 return (
13 - <FixtureSet title="Buttons">
13 + <FixtureSet title="Buttons" description="">
14 <TestCase
15 title="onClick with disabled buttons"
16 description="The onClick event handler should not be invoked when clicking on a disabled buyaton">
fixtures/dom/src/components/fixtures/index.js
+22 -24
@@ -12,29 +12,27 @@ import ButtonFixtures from './buttons';
12 * A simple routing component that renders the appropriate
13 * fixture based on the location pathname.
14 */
15 -const FixturesPage = React.createClass({
16 - render() {
17 - switch (window.location.pathname) {
18 - case '/text-inputs':
19 - return <TextInputFixtures />;
20 - case '/range-inputs':
21 - return <RangeInputFixtures />;
22 - case '/selects':
23 - return <SelectFixtures />;
24 - case '/textareas':
25 - return <TextAreaFixtures />;
26 - case '/input-change-events':
27 - return <InputChangeEvents />;
28 - case '/number-inputs':
29 - return <NumberInputFixtures />;
30 - case '/password-inputs':
31 - return <PasswordInputFixtures />;
32 - case '/buttons':
33 - return <ButtonFixtures />
34 - default:
35 - return <p>Please select a test fixture.</p>;
36 - }
37 - },
38 -});
15 +function FixturesPage() {
16 + switch (window.location.pathname) {
17 + case '/text-inputs':
18 + return <TextInputFixtures />;
19 + case '/range-inputs':
20 + return <RangeInputFixtures />;
21 + case '/selects':
22 + return <SelectFixtures />;
23 + case '/textareas':
24 + return <TextAreaFixtures />;
25 + case '/input-change-events':
26 + return <InputChangeEvents />;
27 + case '/number-inputs':
28 + return <NumberInputFixtures />;
29 + case '/password-inputs':
30 + return <PasswordInputFixtures />;
31 + case '/buttons':
32 + return <ButtonFixtures />
33 + default:
34 + return <p>Please select a test fixture.</p>;
35 + }
36 +}
37
38 module.exports = FixturesPage;
fixtures/dom/src/components/fixtures/number-inputs/NumberTestCase.js
+6 -8
@@ -2,16 +2,14 @@ const React = window.React;
2
3 import Fixture from '../../Fixture';
4
5 -const NumberTestCase = React.createClass({
6 - getInitialState() {
7 - return { value: '' };
8 - },
9 - onChange(event) {
5 +class NumberTestCase extends React.Component {
6 + state = { value: '' };
7 + onChange = (event) => {
8 const parsed = parseFloat(event.target.value, 10)
9 const value = isNaN(parsed) ? '' : parsed
10
11 this.setState({ value })
14 - },
12 + }
13 render() {
14 return (
15 <Fixture>
@@ -31,7 +29,7 @@ const NumberTestCase = React.createClass({
29 </div>
30 </Fixture>
31 );
34 - },
35 -});
32 + }
33 +}
34
35 export default NumberTestCase;
fixtures/dom/src/components/fixtures/number-inputs/index.js
+156 -158
@@ -4,164 +4,162 @@ import FixtureSet from '../../FixtureSet';
4 import TestCase from '../../TestCase';
5 import NumberTestCase from './NumberTestCase';
6
7 -const NumberInputs = React.createClass({
8 - render() {
9 - return (
10 - <FixtureSet
11 - title="Number inputs"
12 - description="Number inputs inconsistently assign and report the value
13 - property depending on the browser."
7 +function NumberInputs() {
8 + return (
9 + <FixtureSet
10 + title="Number inputs"
11 + description="Number inputs inconsistently assign and report the value
12 + property depending on the browser."
13 + >
14 + <TestCase
15 + title="Backspacing"
16 + description="The decimal place should not be lost"
17 >
15 - <TestCase
16 - title="Backspacing"
17 - description="The decimal place should not be lost"
18 - >
19 - <TestCase.Steps>
20 - <li>Type "3.1"</li>
21 - <li>Press backspace, eliminating the "1"</li>
22 - </TestCase.Steps>
23 -
24 - <TestCase.ExpectedResult>
25 - The field should read "3.", preserving the decimal place
26 - </TestCase.ExpectedResult>
27 -
28 - <NumberTestCase />
29 -
30 - <p className="footnote">
31 - <b>Notes:</b> Chrome and Safari clear trailing
32 - decimals on blur. React makes this concession so that the
33 - value attribute remains in sync with the value property.
34 - </p>
35 - </TestCase>
36 -
37 - <TestCase
38 - title="Decimal precision"
39 - description="Supports decimal precision greater than 2 places"
40 - >
41 - <TestCase.Steps>
42 - <li>Type "0.01"</li>
43 - </TestCase.Steps>
44 -
45 - <TestCase.ExpectedResult>
46 - The field should read "0.01"
47 - </TestCase.ExpectedResult>
48 -
49 - <NumberTestCase />
50 - </TestCase>
51 -
52 - <TestCase
53 - title="Exponent form"
54 - description="Supports exponent form ('2e4')"
55 - >
56 - <TestCase.Steps>
57 - <li>Type "2e"</li>
58 - <li>Type 4, to read "2e4"</li>
59 - </TestCase.Steps>
60 -
61 - <TestCase.ExpectedResult>
62 - The field should read "2e4". The parsed value should read "20000"
63 - </TestCase.ExpectedResult>
64 -
65 - <NumberTestCase />
66 - </TestCase>
67 -
68 - <TestCase
69 - title="Exponent Form"
70 - description="Pressing 'e' at the end"
71 - >
72 - <TestCase.Steps>
73 - <li>Type "3.14"</li>
74 - <li>Press "e", so that the input reads "3.14e"</li>
75 - </TestCase.Steps>
76 -
77 - <TestCase.ExpectedResult>
78 - The field should read "3.14e", the parsed value should be empty
79 - </TestCase.ExpectedResult>
80 -
81 - <NumberTestCase />
82 - </TestCase>
83 -
84 - <TestCase
85 - title="Exponent Form"
86 - description="Supports pressing 'ee' in the middle of a number"
87 - >
88 - <TestCase.Steps>
89 - <li>Type "3.14"</li>
90 - <li>Move the text cursor to after the decimal place</li>
91 - <li>Press "e" twice, so that the value reads "3.ee14"</li>
92 - </TestCase.Steps>
93 -
94 - <TestCase.ExpectedResult>
95 - The field should read "3.ee14"
96 - </TestCase.ExpectedResult>
97 -
98 - <NumberTestCase />
99 - </TestCase>
100 -
101 - <TestCase
102 - title="Trailing Zeroes"
103 - description="Typing '3.0' preserves the trailing zero"
104 - >
105 - <TestCase.Steps>
106 - <li>Type "3.0"</li>
107 - </TestCase.Steps>
108 -
109 - <TestCase.ExpectedResult>
110 - The field should read "3.0"
111 - </TestCase.ExpectedResult>
112 -
113 - <NumberTestCase />
114 - </TestCase>
115 -
116 - <TestCase
117 - title="Inserting decimals precision"
118 - description="Inserting '.' in to '300' maintains the trailing zeroes"
119 - >
120 - <TestCase.Steps>
121 - <li>Type "300"</li>
122 - <li>Move the cursor to after the "3"</li>
123 - <li>Type "."</li>
124 - </TestCase.Steps>
125 -
126 - <TestCase.ExpectedResult>
127 - The field should read "3.00", not "3"
128 - </TestCase.ExpectedResult>
129 - <NumberTestCase />
130 - </TestCase>
131 -
132 - <TestCase
133 - title="Replacing numbers with -"
134 - description="Replacing a number with the '-' sign should not clear the value"
135 - >
136 - <TestCase.Steps>
137 - <li>Type "3"</li>
138 - <li>Select the entire value"</li>
139 - <li>Type '-' to replace '3' with '-'</li>
140 - </TestCase.Steps>
141 -
142 - <TestCase.ExpectedResult>
143 - The field should read "-", not be blank.
144 - </TestCase.ExpectedResult>
145 - <NumberTestCase />
146 - </TestCase>
147 -
148 - <TestCase
149 - title="Negative numbers"
150 - description="Typing minus when inserting a negative number should work"
151 - >
152 - <TestCase.Steps>
153 - <li>Type "-"</li>
154 - <li>Type '3'</li>
155 - </TestCase.Steps>
156 -
157 - <TestCase.ExpectedResult>
158 - The field should read "-3".
159 - </TestCase.ExpectedResult>
160 - <NumberTestCase />
161 - </TestCase>
162 - </FixtureSet>
163 - );
164 - },
165 -});
18 + <TestCase.Steps>
19 + <li>Type "3.1"</li>
20 + <li>Press backspace, eliminating the "1"</li>
21 + </TestCase.Steps>
22 +
23 + <TestCase.ExpectedResult>
24 + The field should read "3.", preserving the decimal place
25 + </TestCase.ExpectedResult>
26 +
27 + <NumberTestCase />
28 +
29 + <p className="footnote">
30 + <b>Notes:</b> Chrome and Safari clear trailing
31 + decimals on blur. React makes this concession so that the
32 + value attribute remains in sync with the value property.
33 + </p>
34 + </TestCase>
35 +
36 + <TestCase
37 + title="Decimal precision"
38 + description="Supports decimal precision greater than 2 places"
39 + >
40 + <TestCase.Steps>
41 + <li>Type "0.01"</li>
42 + </TestCase.Steps>
43 +
44 + <TestCase.ExpectedResult>
45 + The field should read "0.01"
46 + </TestCase.ExpectedResult>
47 +
48 + <NumberTestCase />
49 + </TestCase>
50 +
51 + <TestCase
52 + title="Exponent form"
53 + description="Supports exponent form ('2e4')"
54 + >
55 + <TestCase.Steps>
56 + <li>Type "2e"</li>
57 + <li>Type 4, to read "2e4"</li>
58 + </TestCase.Steps>
59 +
60 + <TestCase.ExpectedResult>
61 + The field should read "2e4". The parsed value should read "20000"
62 + </TestCase.ExpectedResult>
63 +
64 + <NumberTestCase />
65 + </TestCase>
66 +
67 + <TestCase
68 + title="Exponent Form"
69 + description="Pressing 'e' at the end"
70 + >
71 + <TestCase.Steps>
72 + <li>Type "3.14"</li>
73 + <li>Press "e", so that the input reads "3.14e"</li>
74 + </TestCase.Steps>
75 +
76 + <TestCase.ExpectedResult>
77 + The field should read "3.14e", the parsed value should be empty
78 + </TestCase.ExpectedResult>
79 +
80 + <NumberTestCase />
81 + </TestCase>
82 +
83 + <TestCase
84 + title="Exponent Form"
85 + description="Supports pressing 'ee' in the middle of a number"
86 + >
87 + <TestCase.Steps>
88 + <li>Type "3.14"</li>
89 + <li>Move the text cursor to after the decimal place</li>
90 + <li>Press "e" twice, so that the value reads "3.ee14"</li>
91 + </TestCase.Steps>
92 +
93 + <TestCase.ExpectedResult>
94 + The field should read "3.ee14"
95 + </TestCase.ExpectedResult>
96 +
97 + <NumberTestCase />
98 + </TestCase>
99 +
100 + <TestCase
101 + title="Trailing Zeroes"
102 + description="Typing '3.0' preserves the trailing zero"
103 + >
104 + <TestCase.Steps>
105 + <li>Type "3.0"</li>
106 + </TestCase.Steps>
107 +
108 + <TestCase.ExpectedResult>
109 + The field should read "3.0"
110 + </TestCase.ExpectedResult>
111 +
112 + <NumberTestCase />
113 + </TestCase>
114 +
115 + <TestCase
116 + title="Inserting decimals precision"
117 + description="Inserting '.' in to '300' maintains the trailing zeroes"
118 + >
119 + <TestCase.Steps>
120 + <li>Type "300"</li>
121 + <li>Move the cursor to after the "3"</li>
122 + <li>Type "."</li>
123 + </TestCase.Steps>
124 +
125 + <TestCase.ExpectedResult>
126 + The field should read "3.00", not "3"
127 + </TestCase.ExpectedResult>
128 + <NumberTestCase />
129 + </TestCase>
130 +
131 + <TestCase
132 + title="Replacing numbers with -"
133 + description="Replacing a number with the '-' sign should not clear the value"
134 + >
135 + <TestCase.Steps>
136 + <li>Type "3"</li>
137 + <li>Select the entire value"</li>
138 + <li>Type '-' to replace '3' with '-'</li>
139 + </TestCase.Steps>
140 +
141 + <TestCase.ExpectedResult>
142 + The field should read "-", not be blank.
143 + </TestCase.ExpectedResult>
144 + <NumberTestCase />
145 + </TestCase>
146 +
147 + <TestCase
148 + title="Negative numbers"
149 + description="Typing minus when inserting a negative number should work"
150 + >
151 + <TestCase.Steps>
152 + <li>Type "-"</li>
153 + <li>Type '3'</li>
154 + </TestCase.Steps>
155 +
156 + <TestCase.ExpectedResult>
157 + The field should read "-3".
158 + </TestCase.ExpectedResult>
159 + <NumberTestCase />
160 + </TestCase>
161 + </FixtureSet>
162 + );
163 +}
164
165 export default NumberInputs;
fixtures/dom/src/components/fixtures/password-inputs/PasswordTestCase.js
+6 -8
@@ -2,13 +2,11 @@ const React = window.React;
2
3 import Fixture from '../../Fixture';
4
5 -const PasswordTestCase = React.createClass({
6 - getInitialState() {
7 - return { value: '' };
8 - },
9 - onChange(event) {
5 +class PasswordTestCase extends React.Component {
6 + state = { value: '' };
7 + onChange = (event) => {
8 this.setState({ value: event.target.value })
11 - },
9 + }
10 render() {
11 return (
12 <Fixture>
@@ -28,7 +26,7 @@ const PasswordTestCase = React.createClass({
26 </div>
27 </Fixture>
28 );
31 - },
32 -});
29 + }
30 +}
31
32 export default PasswordTestCase;
fixtures/dom/src/components/fixtures/password-inputs/index.js
+21 -23
@@ -4,30 +4,28 @@ import FixtureSet from '../../FixtureSet';
4 import TestCase from '../../TestCase';
5 import PasswordTestCase from './PasswordTestCase'
6
7 -const NumberInputs = React.createClass({
8 - render() {
9 - return (
10 - <FixtureSet title="Password inputs" description="">
11 - <TestCase
12 - title="The show password icon"
13 - description={`
14 - Some browsers have an unmask password icon that React accidentally
15 - prevents the display of.
16 - `}
17 - affectedBrowsers="IE Edge, IE 11">
18 - <TestCase.Steps>
19 - <li>Type any string (not an actual password</li>
20 - </TestCase.Steps>
7 +function NumberInputs() {
8 + return (
9 + <FixtureSet title="Password inputs" description="">
10 + <TestCase
11 + title="The show password icon"
12 + description={`
13 + Some browsers have an unmask password icon that React accidentally
14 + prevents the display of.
15 + `}
16 + affectedBrowsers="IE Edge, IE 11">
17 + <TestCase.Steps>
18 + <li>Type any string (not an actual password</li>
19 + </TestCase.Steps>
20
22 - <TestCase.ExpectedResult>
23 - The field should include the "unmasking password" icon.
24 - </TestCase.ExpectedResult>
21 + <TestCase.ExpectedResult>
22 + The field should include the "unmasking password" icon.
23 + </TestCase.ExpectedResult>
24
26 - <PasswordTestCase />
27 - </TestCase>
28 - </FixtureSet>
29 - );
30 - },
31 -});
25 + <PasswordTestCase />
26 + </TestCase>
27 + </FixtureSet>
28 + );
29 +}
30
31 export default NumberInputs;
fixtures/dom/src/components/fixtures/range-inputs/index.js
+6 -8
@@ -1,12 +1,10 @@
1 const React = window.React;
2
3 -const RangeInputs = React.createClass({
4 - getInitialState() {
5 - return { value: 0.5 };
6 - },
7 - onChange(event) {
3 +class RangeInputs extends React.Component {
4 + state = { value: 0.5 };
5 + onChange = (event) => {
6 this.setState({ value: event.target.value });
9 - },
7 + }
8 render() {
9 return (
10 <form>
@@ -22,7 +20,7 @@ const RangeInputs = React.createClass({
20 </fieldset>
21 </form>
22 );
25 - },
26 -});
23 + }
24 +}
25
26 export default RangeInputs;
fixtures/dom/src/components/fixtures/selects/index.js
+6 -8
@@ -1,12 +1,10 @@
1 const React = window.React;
2
3 -const SelectFixture = React.createClass({
4 - getInitialState() {
5 - return { value: '' };
6 - },
7 - onChange(event) {
3 +class SelectFixture extends React.Component {
4 + state = { value: '' };
5 + onChange = (event) => {
6 this.setState({ value: event.target.value });
9 - },
7 + }
8 render() {
9 return (
10 <form>
@@ -31,7 +29,7 @@ const SelectFixture = React.createClass({
29 </fieldset>
30 </form>
31 );
34 - },
35 -});
32 + }
33 +}
34
35 export default SelectFixture;
fixtures/dom/src/components/fixtures/text-inputs/index.js
+10 -12
@@ -1,13 +1,11 @@
1 const React = window.React;
2
3 -const TextInputFixtures = React.createClass({
4 - getInitialState() {
5 - return {
6 - color: '#ffaaee',
7 - };
8 - },
3 +class TextInputFixtures extends React.Component {
4 + state = {
5 + color: '#ffaaee',
6 + };
7
10 - renderControlled(type) {
8 + renderControlled = (type) => {
9 let id = `controlled_${type}`;
10
11 let onChange = e => {
@@ -29,9 +27,9 @@ const TextInputFixtures = React.createClass({
27 &nbsp; &rarr; {JSON.stringify(state)}
28 </div>
29 );
32 - },
30 + }
31
34 - renderUncontrolled(type) {
32 + renderUncontrolled = (type) => {
33 let id = `uncontrolled_${type}`;
34 return (
35 <div key={type} className="field">
@@ -39,7 +37,7 @@ const TextInputFixtures = React.createClass({
37 <input id={id} type={type} />
38 </div>
39 );
42 - },
40 + }
41
42 render() {
43 // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
@@ -60,7 +58,7 @@ const TextInputFixtures = React.createClass({
58 </fieldset>
59 </form>
60 );
63 - },
64 -});
61 + }
62 +}
63
64 module.exports = TextInputFixtures;
fixtures/dom/src/components/fixtures/textareas/index.js
+6 -8
@@ -1,12 +1,10 @@
1 const React = window.React;
2
3 -const TextAreaFixtures = React.createClass({
4 - getInitialState() {
5 - return { value: '' };
6 - },
7 - onChange(event) {
3 +class TextAreaFixtures extends React.Component {
4 + state = { value: '' };
5 + onChange = (event) => {
6 this.setState({ value: event.target.value });
9 - },
7 + }
8 render() {
9 return (
10 <div>
@@ -30,7 +28,7 @@ const TextAreaFixtures = React.createClass({
28 </div>
29 </div>
30 );
33 - },
34 -});
31 + }
32 +}
33
34 module.exports = TextAreaFixtures;
fixtures/dom/src/components/propTypes.js
+2 -3
@@ -1,11 +1,10 @@
1 +import PropTypes from 'prop-types';
2 import semver from 'semver';
3
3 -const React = window.React;
4 -
4 export function semverString (props, propName, componentName) {
5 let version = props[propName];
6
8 - let error = React.PropTypes.string(...arguments);
7 + let error = PropTypes.string(...arguments);
8 if (!error && version != null && !semver.valid(version))
9 error = new Error(
10 `\`${propName}\` should be a valid "semantic version" matching ` +
fixtures/dom/yarn.lock
+6
@@ -4239,6 +4239,12 @@ promise@7.1.1, promise@^7.1.1:
4239 dependencies:
4240 asap "~2.0.3"
4241
4242 +prop-types@^15.5.6:
4243 + version "15.5.6"
4244 + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.6.tgz#797a915b1714b645ebb7c5d6cc690346205bd2aa"
4245 + dependencies:
4246 + fbjs "^0.8.9"
4247 +
4248 proxy-addr@~1.1.2:
4249 version "1.1.2"
4250 resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.2.tgz#b4cc5f22610d9535824c123aef9d3cf73c40ba37"
package.json
+2 -1
@@ -43,7 +43,7 @@
43 "coffee-script": "^1.8.0",
44 "core-js": "^2.2.1",
45 "coveralls": "^2.11.6",
46 - "create-react-class": "^15.5.0",
46 + "create-react-class": "^15.5.2",
47 "del": "^2.0.2",
48 "derequire": "^2.0.3",
49 "escape-string-regexp": "^1.0.5",
@@ -73,6 +73,7 @@
73 "object-assign": "^4.1.1",
74 "platform": "^1.1.0",
75 "prettier": "^0.22.0",
76 + "prop-types": "^15.5.6",
77 "rimraf": "^2.6.1",
78 "rollup": "^0.41.6",
79 "rollup-plugin-alias": "^1.2.1",
packages/react-dom/package.json
+2 -1
@@ -15,7 +15,8 @@
15 "dependencies": {
16 "fbjs": "^0.8.9",
17 "loose-envify": "^1.1.0",
18 - "object-assign": "^4.1.0"
18 + "object-assign": "^4.1.0",
19 + "prop-types": "^15.5.6"
20 },
21 "peerDependencies": {
22 "react": "^16.0.0-alpha.8"
packages/react/package.json
+3 -1
@@ -22,9 +22,11 @@
22 "node": ">=0.10.0"
23 },
24 "dependencies": {
25 + "create-react-class": "^15.5.2",
26 "fbjs": "^0.8.9",
27 "loose-envify": "^1.1.0",
27 - "object-assign": "^4.1.0"
28 + "object-assign": "^4.1.0",
29 + "prop-types": "^15.5.6"
30 },
31 "browserify": {
32 "transform": [
scripts/fiber/tests-passing.txt
+2 -13
@@ -45,6 +45,8 @@ scripts/shared/__tests__/evalToString-test.js
45 src/isomorphic/__tests__/React-test.js
46 * should log a deprecation warning once when using React.createMixin
47 * should warn once when attempting to access React.createClass
48 +* should warn once when attempting to access React.PropTypes
49 +* should warn once when attempting to access React.checkPropTypes
50
51 src/isomorphic/children/__tests__/ReactChildren-test.js
52 * should support identity for simple
@@ -278,19 +280,6 @@ src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
280 * should have received the validator's return value
281 * should not warn if the validator returned null
282
281 -src/isomorphic/classic/types/__tests__/ReactPropTypesProduction-test.js
282 -* should be a no-op
283 -* should be a no-op
284 -* should be a no-op
285 -* should be a no-op
286 -* should be a no-op
287 -* should be a no-op
288 -* should be a no-op
289 -* should be a no-op
290 -* should be a no-op
291 -* should be a no-op
292 -* should not have been called
293 -
283 src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js
284 * tests the same thing for es6 classes and CoffeeScript
285 * tests the same thing for es6 classes and TypeScript
scripts/jest/ts-preprocessor.js
+1 -1
@@ -23,7 +23,7 @@ function compile(content, contentFilename) {
23 getSourceFile(filename, languageVersion) {
24 var source;
25 var jestRegex = /jest\.d\.ts/;
26 - var reactRegex = /(?:React|ReactDOM)(?:\.d)?\.ts$/;
26 + var reactRegex = /(?:React|ReactDOM|PropTypes)(?:\.d)?\.ts$/;
27
28 // `path.normalize` is used to turn forward slashes in
29 // the file path into backslashes on Windows.
scripts/rollup/bundles.js
+22 -7
@@ -45,7 +45,12 @@ const bundles = [
45 sourceMap: false,
46 },
47 entry: 'src/isomorphic/React.js',
48 - externals: [],
48 + externals: [
49 + 'create-react-class/factory',
50 + 'prop-types',
51 + 'prop-types/checkPropTypes',
52 + 'prop-types/factory',
53 + ],
54 fbEntry: 'src/fb/ReactFBEntry.js',
55 hasteName: 'React',
56 isRenderer: false,
@@ -74,7 +79,7 @@ const bundles = [
79 sourceMap: false,
80 },
81 entry: 'src/renderers/dom/ReactDOM.js',
77 - externals: [],
82 + externals: ['prop-types', 'prop-types/checkPropTypes'],
83 fbEntry: 'src/fb/ReactDOMFBEntry.js',
84 hasteName: 'ReactDOMStack',
85 isRenderer: true,
@@ -86,6 +91,7 @@ const bundles = [
91 'src/renderers/shared/**/*.js',
92 'src/test/**/*.js', // ReactTestUtils is currently very coupled to DOM.
93
94 + 'src/isomorphic/classic/types/checkPropTypes.js',
95 'src/ReactVersion.js',
96 'src/shared/**/*.js',
97 ],
@@ -102,7 +108,7 @@ const bundles = [
108 sourceMap: false,
109 },
110 entry: 'src/renderers/dom/fiber/ReactDOMFiber.js',
105 - externals: [],
111 + externals: ['prop-types', 'prop-types/checkPropTypes'],
112 fbEntry: 'src/fb/ReactDOMFiberFBEntry.js',
113 hasteName: 'ReactDOMFiber',
114 isRenderer: true,
@@ -114,6 +120,7 @@ const bundles = [
120 'src/renderers/shared/**/*.js',
121 'src/test/**/*.js', // ReactTestUtils is currently very coupled to DOM.
122
123 + 'src/isomorphic/classic/types/checkPropTypes.js',
124 'src/ReactVersion.js',
125 'src/shared/**/*.js',
126 ],
@@ -133,7 +140,7 @@ const bundles = [
140 sourceMap: false,
141 },
142 entry: 'src/renderers/dom/ReactDOMServer.js',
136 - externals: [],
143 + externals: ['prop-types', 'prop-types/checkPropTypes'],
144 fbEntry: 'src/renderers/dom/ReactDOMServer.js',
145 hasteName: 'ReactDOMServerStack',
146 isRenderer: true,
@@ -144,6 +151,7 @@ const bundles = [
151 'src/renderers/dom/**/*.js',
152 'src/renderers/shared/**/*.js',
153
154 + 'src/isomorphic/classic/types/checkPropTypes.js',
155 'src/ReactVersion.js',
156 'src/shared/**/*.js',
157 ],
@@ -169,6 +177,7 @@ const bundles = [
177 'art/modes/current',
178 'art/modes/fast-noSideEffects',
179 'art/core/transform',
180 + 'prop-types/checkPropTypes',
181 'react-dom',
182 ],
183 fbEntry: 'src/renderers/art/ReactARTStack.js',
@@ -181,6 +190,7 @@ const bundles = [
190 'src/renderers/art/**/*.js',
191 'src/renderers/shared/**/*.js',
192
193 + 'src/isomorphic/classic/types/checkPropTypes.js',
194 'src/ReactVersion.js',
195 'src/shared/**/*.js',
196 ],
@@ -203,6 +213,7 @@ const bundles = [
213 'art/modes/current',
214 'art/modes/fast-noSideEffects',
215 'art/core/transform',
216 + 'prop-types/checkPropTypes',
217 'react-dom',
218 ],
219 fbEntry: 'src/renderers/art/ReactARTFiber.js',
@@ -215,6 +226,7 @@ const bundles = [
226 'src/renderers/art/**/*.js',
227 'src/renderers/shared/**/*.js',
228
229 + 'src/isomorphic/classic/types/checkPropTypes.js',
230 'src/ReactVersion.js',
231 'src/shared/**/*.js',
232 ],
@@ -304,7 +316,7 @@ const bundles = [
316 sourceMap: false,
317 },
318 entry: 'src/renderers/testing/ReactTestRendererFiber',
307 - externals: [],
319 + externals: ['prop-types/checkPropTypes'],
320 fbEntry: 'src/renderers/testing/ReactTestRendererFiber',
321 hasteName: 'ReactTestRendererFiber',
322 isRenderer: true,
@@ -316,6 +328,7 @@ const bundles = [
328 'src/renderers/shared/**/*.js',
329 'src/renderers/testing/**/*.js',
330
331 + 'src/isomorphic/classic/types/checkPropTypes.js',
332 'src/ReactVersion.js',
333 'src/shared/**/*.js',
334 ],
@@ -330,7 +343,7 @@ const bundles = [
343 sourceMap: false,
344 },
345 entry: 'src/renderers/testing/stack/ReactTestRendererStack',
333 - externals: [],
346 + externals: ['prop-types/checkPropTypes'],
347 fbEntry: 'src/renderers/testing/stack/ReactTestRendererStack',
348 hasteName: 'ReactTestRendererStack',
349 isRenderer: true,
@@ -342,6 +355,7 @@ const bundles = [
355 'src/renderers/shared/**/*.js',
356 'src/renderers/testing/**/*.js',
357
358 + 'src/isomorphic/classic/types/checkPropTypes.js',
359 'src/ReactVersion.js',
360 'src/shared/**/*.js',
361 ],
@@ -360,7 +374,7 @@ const bundles = [
374 sourceMap: false,
375 },
376 entry: 'src/renderers/noop/ReactNoop.js',
363 - externals: [],
377 + externals: ['prop-types/checkPropTypes'],
378 isRenderer: true,
379 label: 'noop-fiber',
380 manglePropertiesOnProd: false,
@@ -369,6 +383,7 @@ const bundles = [
383 'src/renderers/noop/**/*.js',
384 'src/renderers/shared/**/*.js',
385
386 + 'src/isomorphic/classic/types/checkPropTypes.js',
387 'src/ReactVersion.js',
388 'src/shared/**/*.js',
389 ],
scripts/rollup/modules.js
+33 -1
@@ -52,6 +52,14 @@ const devOnlyFilesToStubOut = [
52 "'ReactTestUtils'",
53 ];
54
55 +const legacyModules = [
56 + 'create-react-class',
57 + 'create-react-class/factory',
58 + 'prop-types',
59 + 'prop-types/checkPropTypes',
60 + 'prop-types/factory',
61 +];
62 +
63 // this function builds up a very niave Haste-like moduleMap
64 // that works to create up an alias map for modules to link
65 // up to their actual disk location so Rollup can properly
@@ -230,6 +238,29 @@ function replaceDevOnlyStubbedModules(bundleType) {
238 }
239 }
240
241 +function replaceLegacyModuleAliases(bundleType) {
242 + switch (bundleType) {
243 + case UMD_DEV:
244 + case UMD_PROD:
245 + const modulesAlias = {};
246 + legacyModules.forEach(legacyModule => {
247 + const modulePath = legacyModule.includes('/')
248 + ? legacyModule
249 + : `${legacyModule}/index`;
250 + const resolvedPath = resolve(`./node_modules/${modulePath}`);
251 + modulesAlias[`'${legacyModule}'`] = `'${resolvedPath}'`;
252 + });
253 + return modulesAlias;
254 + case NODE_DEV:
255 + case NODE_PROD:
256 + case FB_DEV:
257 + case FB_PROD:
258 + case RN_DEV:
259 + case RN_PROD:
260 + return {};
261 + }
262 +}
263 +
264 function getAliases(paths, bundleType, isRenderer, extractErrors) {
265 return Object.assign(
266 createModuleMap(
@@ -247,7 +278,8 @@ function getDefaultReplaceModules(bundleType) {
278 return Object.assign(
279 {},
280 replaceFbjsModuleAliases(bundleType),
250 - replaceDevOnlyStubbedModules(bundleType)
281 + replaceDevOnlyStubbedModules(bundleType),
282 + replaceLegacyModuleAliases(bundleType)
283 );
284 }
285
scripts/rollup/results.json
+64 -64
@@ -1,117 +1,117 @@
1 {
2 - "branch": "bundle-fixes",
2 + "branch": "prop-types",
3 "bundleSizes": {
4 "react.development.js (UMD_DEV)": {
5 - "size": 116098,
6 - "gzip": 29520
5 + "size": 121474,
6 + "gzip": 30524
7 },
8 "react.production.min.js (UMD_PROD)": {
9 - "size": 13707,
10 - "gzip": 5073
9 + "size": 15685,
10 + "gzip": 5765
11 },
12 "react-dom.development.js (UMD_DEV)": {
13 - "size": 563844,
14 - "gzip": 130190
13 + "size": 583352,
14 + "gzip": 134572
15 },
16 "react-dom.production.min.js (UMD_PROD)": {
17 - "size": 120191,
18 - "gzip": 37860
17 + "size": 120740,
18 + "gzip": 38092
19 },
20 "react-dom-server.development.js (UMD_DEV)": {
21 - "size": 476049,
22 - "gzip": 115267
21 + "size": 495558,
22 + "gzip": 119685
23 },
24 "react-dom-server.production.min.js (UMD_PROD)": {
25 - "size": 106489,
26 - "gzip": 33035
25 + "size": 107033,
26 + "gzip": 33273
27 },
28 "react-art.development.js (UMD_DEV)": {
29 - "size": 339929,
30 - "gzip": 76018
29 + "size": 342770,
30 + "gzip": 76828
31 },
32 "react-art.production.min.js (UMD_PROD)": {
33 "size": 95013,
34 - "gzip": 28991
34 + "gzip": 28990
35 },
36 "react.development.js (NODE_DEV)": {
37 - "size": 109110,
38 - "gzip": 27479
37 + "size": 70286,
38 + "gzip": 17600
39 },
40 "react.production.min.js (NODE_PROD)": {
41 - "size": 12598,
42 - "gzip": 4649
41 + "size": 9226,
42 + "gzip": 3626
43 },
44 "React-dev.js (FB_DEV)": {
45 - "size": 110875,
46 - "gzip": 28140
45 + "size": 72143,
46 + "gzip": 18236
47 },
48 "React-prod.js (FB_PROD)": {
49 - "size": 56406,
50 - "gzip": 14416
49 + "size": 36643,
50 + "gzip": 9256
51 },
52 "ReactDOMStack-dev.js (FB_DEV)": {
53 - "size": 522626,
54 - "gzip": 124708
53 + "size": 522763,
54 + "gzip": 124727
55 },
56 "ReactDOMStack-prod.js (FB_PROD)": {
57 - "size": 352708,
58 - "gzip": 84660
57 + "size": 352776,
58 + "gzip": 84675
59 },
60 "react-dom.development.js (NODE_DEV)": {
61 - "size": 542218,
62 - "gzip": 125162
61 + "size": 542350,
62 + "gzip": 125199
63 },
64 "react-dom.production.min.js (NODE_PROD)": {
65 - "size": 116858,
66 - "gzip": 36717
65 + "size": 116925,
66 + "gzip": 36732
67 },
68 "ReactDOMFiber-dev.js (FB_DEV)": {
69 - "size": 797268,
70 - "gzip": 184134
69 + "size": 797397,
70 + "gzip": 184161
71 },
72 "ReactDOMFiber-prod.js (FB_PROD)": {
73 - "size": 407540,
74 - "gzip": 93567
73 + "size": 407613,
74 + "gzip": 93586
75 },
76 "react-dom-server.development.js (NODE_DEV)": {
77 - "size": 445452,
78 - "gzip": 107574
77 + "size": 445589,
78 + "gzip": 107597
79 },
80 "react-dom-server.production.min.js (NODE_PROD)": {
81 - "size": 101344,
82 - "gzip": 31273
81 + "size": 101411,
82 + "gzip": 31292
83 },
84 "ReactDOMServerStack-dev.js (FB_DEV)": {
85 - "size": 444144,
86 - "gzip": 107423
85 + "size": 444281,
86 + "gzip": 107443
87 },
88 "ReactDOMServerStack-prod.js (FB_PROD)": {
89 - "size": 333744,
90 - "gzip": 80424
89 + "size": 334166,
90 + "gzip": 80444
91 },
92 "ReactARTStack-dev.js (FB_DEV)": {
93 - "size": 141589,
94 - "gzip": 32280
93 + "size": 142986,
94 + "gzip": 32714
95 },
96 "ReactARTStack-prod.js (FB_PROD)": {
97 - "size": 99762,
98 - "gzip": 22576
97 + "size": 101143,
98 + "gzip": 22993
99 },
100 "react-art.development.js (NODE_DEV)": {
101 - "size": 265123,
102 - "gzip": 56951
101 + "size": 265214,
102 + "gzip": 56974
103 },
104 "react-art.production.min.js (NODE_PROD)": {
105 - "size": 56591,
106 - "gzip": 17132
105 + "size": 56628,
106 + "gzip": 17152
107 },
108 "ReactARTFiber-dev.js (FB_DEV)": {
109 - "size": 264301,
110 - "gzip": 56758
109 + "size": 264392,
110 + "gzip": 56780
111 },
112 "ReactARTFiber-prod.js (FB_PROD)": {
113 - "size": 205292,
114 - "gzip": 43132
113 + "size": 205336,
114 + "gzip": 43154
115 },
116 "ReactNativeStack.js (RN)": {
117 "size": 233993,
@@ -122,20 +122,20 @@
122 "gzip": 84001
123 },
124 "ReactTestRendererFiber-dev.js (FB_DEV)": {
125 - "size": 262210,
126 - "gzip": 55722
125 + "size": 262301,
126 + "gzip": 55747
127 },
128 "ReactTestRendererStack-dev.js (FB_DEV)": {
129 - "size": 151425,
130 - "gzip": 34728
129 + "size": 151521,
130 + "gzip": 34765
131 },
132 "react-noop-renderer.development.js (NODE_DEV)": {
133 - "size": 254207,
134 - "gzip": 53701
133 + "size": 254298,
134 + "gzip": 53728
135 },
136 "react-test-renderer.development.js (NODE_DEV)": {
137 - "size": 263041,
138 - "gzip": 55919
137 + "size": 263132,
138 + "gzip": 55938
139 }
140 }
141 }
\ No newline at end of file
src/isomorphic/React.js
+40 -4
@@ -20,6 +20,7 @@ var ReactVersion = require('ReactVersion');
20
21 var onlyChild = require('onlyChild');
22 var checkPropTypes = require('checkPropTypes');
23 +var createReactClass = require('createClass');
24
25 var createElement = ReactElement.createElement;
26 var createFactory = ReactElement.createFactory;
@@ -56,11 +57,13 @@ var React = {
57 cloneElement: cloneElement,
58 isValidElement: ReactElement.isValidElement,
59
60 + // TODO (bvaughn) Remove these getters in 16.0.0-alpha.10
61 + PropTypes: ReactPropTypes,
62 checkPropTypes: checkPropTypes,
63 + createClass: createReactClass,
64
65 // Classic
66
63 - PropTypes: ReactPropTypes,
67 createFactory: createFactory,
68 createMixin: createMixin,
69
@@ -82,8 +85,10 @@ if (__DEV__) {
85 ReactDebugCurrentFrame: require('ReactDebugCurrentFrame'),
86 });
87
88 + let warnedForCheckPropTypes = false;
89 let warnedForCreateMixin = false;
90 let warnedForCreateClass = false;
91 + let warnedForPropTypes = false;
92
93 React.createMixin = function(mixin) {
94 warning(
@@ -95,18 +100,49 @@ if (__DEV__) {
100 return mixin;
101 };
102
103 + // TODO (bvaughn) Remove both of these deprecation warnings in 16.0.0-alpha.10
104 if (canDefineProperty) {
105 + Object.defineProperty(React, 'checkPropTypes', {
106 + get() {
107 + warning(
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 ReactPropTypes;
117 + },
118 + });
119 +
120 Object.defineProperty(React, 'createClass', {
121 get: function() {
122 warning(
123 warnedForCreateClass,
124 'React.createClass is no longer supported. Use a plain JavaScript ' +
125 "class instead. If you're not yet ready to migrate, " +
105 - 'create-react-class is available on npm as a temporary, ' +
106 - 'drop-in replacement.',
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;
109 - return undefined;
130 + return createReactClass;
131 + },
132 + });
133 +
134 + Object.defineProperty(React, 'PropTypes', {
135 + get() {
136 + warning(
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 }
src/isomorphic/__tests__/React-test.js
+35 -5
@@ -32,13 +32,43 @@ describe('React', () => {
32 spyOn(console, 'error');
33 let createClass = React.createClass;
34 createClass = React.createClass;
35 - expect(createClass).toBe(undefined);
35 + expect(createClass).not.toBe(undefined);
36 expectDev(console.error.calls.count()).toBe(1);
37 expectDev(console.error.calls.argsFor(0)[0]).toContain(
38 - 'React.createClass is no longer supported. Use a plain ' +
39 - "JavaScript class instead. If you're not yet ready to migrate, " +
40 - 'create-react-class is available on npm as a temporary, ' +
41 - 'drop-in replacement.',
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, 'error');
47 + let PropTypes = React.PropTypes;
48 + PropTypes = React.PropTypes;
49 + expect(PropTypes).not.toBe(undefined);
50 + expectDev(console.error.calls.count()).toBe(1);
51 + expectDev(console.error.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, 'error');
62 + let checkPropTypes = React.checkPropTypes;
63 + checkPropTypes = React.checkPropTypes;
64 + expect(checkPropTypes).not.toBe(undefined);
65 + expectDev(console.error.calls.count()).toBe(1);
66 + expectDev(console.error.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__/ReactContextValidator-test.js
+22 -20
@@ -17,6 +17,7 @@
17
18 'use strict';
19
20 +var PropTypes;
21 var React;
22 var ReactDOM;
23 var ReactTestUtils;
@@ -29,6 +30,7 @@ describe('ReactContextValidator', () => {
30 beforeEach(() => {
31 jest.resetModules();
32
33 + PropTypes = require('prop-types');
34 React = require('react');
35 ReactDOM = require('react-dom');
36 ReactTestUtils = require('ReactTestUtils');
@@ -44,7 +46,7 @@ describe('ReactContextValidator', () => {
46 }
47 }
48 Component.contextTypes = {
47 - foo: React.PropTypes.string,
49 + foo: PropTypes.string,
50 };
51
52 class ComponentInFooBarContext extends React.Component {
@@ -60,8 +62,8 @@ describe('ReactContextValidator', () => {
62 }
63 }
64 ComponentInFooBarContext.childContextTypes = {
63 - foo: React.PropTypes.string,
64 - bar: React.PropTypes.number,
65 + foo: PropTypes.string,
66 + bar: PropTypes.number,
67 };
68
69 var instance = ReactTestUtils.renderIntoDocument(
@@ -88,8 +90,8 @@ describe('ReactContextValidator', () => {
90 }
91 }
92 Parent.childContextTypes = {
91 - foo: React.PropTypes.string.isRequired,
92 - bar: React.PropTypes.string.isRequired,
93 + foo: PropTypes.string.isRequired,
94 + bar: PropTypes.string.isRequired,
95 };
96
97 class Component extends React.Component {
@@ -112,7 +114,7 @@ describe('ReactContextValidator', () => {
114 }
115 }
116 Component.contextTypes = {
115 - foo: React.PropTypes.string,
117 + foo: PropTypes.string,
118 };
119
120 var container = document.createElement('div');
@@ -139,8 +141,8 @@ describe('ReactContextValidator', () => {
141 }
142 }
143 Parent.childContextTypes = {
142 - foo: React.PropTypes.string.isRequired,
143 - bar: React.PropTypes.string.isRequired,
144 + foo: PropTypes.string.isRequired,
145 + bar: PropTypes.string.isRequired,
146 };
147
148 class Component extends React.Component {
@@ -153,7 +155,7 @@ describe('ReactContextValidator', () => {
155 }
156 }
157 Component.contextTypes = {
156 - foo: React.PropTypes.string,
158 + foo: PropTypes.string,
159 };
160
161 var container = document.createElement('div');
@@ -171,7 +173,7 @@ describe('ReactContextValidator', () => {
173 }
174 }
175 Component.contextTypes = {
174 - foo: React.PropTypes.string.isRequired,
176 + foo: PropTypes.string.isRequired,
177 };
178
179 ReactTestUtils.renderIntoDocument(<Component />);
@@ -196,7 +198,7 @@ describe('ReactContextValidator', () => {
198 }
199 }
200 ComponentInFooStringContext.childContextTypes = {
199 - foo: React.PropTypes.string,
201 + foo: PropTypes.string,
202 };
203
204 ReactTestUtils.renderIntoDocument(
@@ -218,7 +220,7 @@ describe('ReactContextValidator', () => {
220 }
221 }
222 ComponentInFooNumberContext.childContextTypes = {
221 - foo: React.PropTypes.number,
223 + foo: PropTypes.number,
224 };
225
226 ReactTestUtils.renderIntoDocument(
@@ -248,8 +250,8 @@ describe('ReactContextValidator', () => {
250 }
251 }
252 Component.childContextTypes = {
251 - foo: React.PropTypes.string.isRequired,
252 - bar: React.PropTypes.number,
253 + foo: PropTypes.string.isRequired,
254 + bar: PropTypes.number,
255 };
256
257 ReactTestUtils.renderIntoDocument(<Component testContext={{bar: 123}} />);
@@ -288,7 +290,7 @@ describe('ReactContextValidator', () => {
290
291 class ComponentA extends React.Component {
292 static childContextTypes = {
291 - foo: React.PropTypes.string.isRequired,
293 + foo: PropTypes.string.isRequired,
294 };
295 render() {
296 return <div />;
@@ -296,7 +298,7 @@ describe('ReactContextValidator', () => {
298 }
299 class ComponentB extends React.Component {
300 static childContextTypes = {
299 - foo: React.PropTypes.string.isRequired,
301 + foo: PropTypes.string.isRequired,
302 };
303 render() {
304 return <div />;
@@ -330,7 +332,7 @@ describe('ReactContextValidator', () => {
332
333 class ParentContextProvider extends React.Component {
334 static childContextTypes = {
333 - foo: React.PropTypes.number,
335 + foo: PropTypes.number,
336 };
337 getChildContext() {
338 return {
@@ -344,7 +346,7 @@ describe('ReactContextValidator', () => {
346
347 class MiddleMissingContext extends React.Component {
348 static childContextTypes = {
347 - bar: React.PropTypes.string.isRequired,
349 + bar: PropTypes.string.isRequired,
350 };
351 render() {
352 return <ChildContextConsumer />;
@@ -359,8 +361,8 @@ describe('ReactContextValidator', () => {
361 }
362 }
363 ChildContextConsumer.contextTypes = {
362 - bar: React.PropTypes.string.isRequired,
363 - foo: React.PropTypes.string.isRequired,
364 + bar: PropTypes.string.isRequired,
365 + foo: PropTypes.string.isRequired,
366 };
367
368 ReactTestUtils.renderIntoDocument(<ParentContextProvider />);
src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js
+9 -7
@@ -11,6 +11,7 @@
11
12 'use strict';
13
14 +var PropTypes;
15 var React;
16 var ReactDOM;
17 var ReactTestUtils;
@@ -18,8 +19,9 @@ var createReactClass;
19
20 describe('create-react-class-integration', () => {
21 beforeEach(() => {
21 - React = require('React');
22 - ReactDOM = require('ReactDOM');
22 + PropTypes = require('prop-types');
23 + React = require('react');
24 + ReactDOM = require('react-dom');
25 ReactTestUtils = require('ReactTestUtils');
26 var createReactClassFactory = require('create-react-class/factory');
27 createReactClass = createReactClassFactory(
@@ -188,13 +190,13 @@ describe('create-react-class-integration', () => {
190 createReactClass({
191 mixins: [{}],
192 propTypes: {
191 - foo: React.PropTypes.string,
193 + foo: PropTypes.string,
194 },
195 contextTypes: {
194 - foo: React.PropTypes.string,
196 + foo: PropTypes.string,
197 },
198 childContextTypes: {
197 - foo: React.PropTypes.string,
199 + foo: PropTypes.string,
200 },
201 render: function() {
202 return <div />;
@@ -268,7 +270,7 @@ describe('create-react-class-integration', () => {
270 it('renders based on context getInitialState', () => {
271 var Foo = createReactClass({
272 contextTypes: {
271 - className: React.PropTypes.string,
273 + className: PropTypes.string,
274 },
275 getInitialState() {
276 return {className: this.context.className};
@@ -280,7 +282,7 @@ describe('create-react-class-integration', () => {
282
283 var Outer = createReactClass({
284 childContextTypes: {
283 - className: React.PropTypes.string,
285 + className: PropTypes.string,
286 },
287 getChildContext() {
288 return {className: 'foo'};
src/isomorphic/classic/class/createClass.js new
+19
@@ -0,0 +1,19 @@
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/element/__tests__/ReactElementClone-test.js
+5 -3
@@ -11,6 +11,7 @@
11
12 'use strict';
13
14 +var PropTypes;
15 var React;
16 var ReactDOM;
17 var ReactTestUtils;
@@ -19,6 +20,7 @@ describe('ReactElementClone', () => {
20 var ComponentClass;
21
22 beforeEach(() => {
23 + PropTypes = require('prop-types');
24 React = require('react');
25 ReactDOM = require('react-dom');
26 ReactTestUtils = require('ReactTestUtils');
@@ -288,13 +290,13 @@ describe('ReactElementClone', () => {
290 it('should check declared prop types after clone', () => {
291 spyOn(console, 'error');
292 class Component extends React.Component {
293 + static propTypes = {
294 + color: PropTypes.string.isRequired,
295 + };
296 render() {
297 return React.createElement('div', null, 'My color is ' + this.color);
298 }
299 }
295 - Component.propTypes = {
296 - color: React.PropTypes.string.isRequired,
297 - };
300 class Parent extends React.Component {
301 render() {
302 return React.cloneElement(this.props.child, {color: 123});
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
+13 -11
@@ -14,6 +14,7 @@
14 // NOTE: We're explicitly not using JSX in this file. This is intended to test
15 // classic JS without JSX.
16
17 +var PropTypes;
18 var React;
19 var ReactDOM;
20 var ReactTestUtils;
@@ -28,6 +29,7 @@ describe('ReactElementValidator', () => {
29 beforeEach(() => {
30 jest.resetModules();
31
32 + PropTypes = require('prop-types');
33 React = require('react');
34 ReactDOM = require('react-dom');
35 ReactTestUtils = require('ReactTestUtils');
@@ -247,7 +249,7 @@ describe('ReactElementValidator', () => {
249 return React.createElement('div', null, 'My color is ' + props.color);
250 }
251 MyComp.propTypes = {
250 - color: React.PropTypes.string,
252 + color: PropTypes.string,
253 };
254 function ParentComp() {
255 return React.createElement(MyComp, {color: 123});
@@ -332,12 +334,12 @@ describe('ReactElementValidator', () => {
334 spyOn(console, 'error');
335
336 class Component extends React.Component {
337 + static propTypes = {prop: PropTypes.string.isRequired};
338 + static defaultProps = {prop: null};
339 render() {
340 return React.createElement('span', null, this.props.prop);
341 }
342 }
339 - Component.propTypes = {prop: React.PropTypes.string.isRequired};
340 - Component.defaultProps = {prop: null};
343
344 ReactTestUtils.renderIntoDocument(React.createElement(Component));
345
@@ -353,12 +355,12 @@ describe('ReactElementValidator', () => {
355 spyOn(console, 'error');
356
357 class Component extends React.Component {
358 + static propTypes = {prop: PropTypes.string.isRequired};
359 + static defaultProps = {prop: 'text'};
360 render() {
361 return React.createElement('span', null, this.props.prop);
362 }
363 }
360 - Component.propTypes = {prop: React.PropTypes.string.isRequired};
361 - Component.defaultProps = {prop: 'text'};
364
365 ReactTestUtils.renderIntoDocument(
366 React.createElement(Component, {prop: null}),
@@ -376,13 +378,13 @@ describe('ReactElementValidator', () => {
378 spyOn(console, 'error');
379
380 class Component extends React.Component {
381 + static propTypes = {
382 + prop: PropTypes.string.isRequired,
383 + };
384 render() {
385 return React.createElement('span', null, this.props.prop);
386 }
387 }
383 - Component.propTypes = {
384 - prop: React.PropTypes.string.isRequired,
385 - };
388
389 ReactTestUtils.renderIntoDocument(React.createElement(Component));
390 ReactTestUtils.renderIntoDocument(
@@ -416,13 +418,13 @@ describe('ReactElementValidator', () => {
418 spyOn(console, 'error');
419
420 class Component extends React.Component {
421 + static propTypes = {
422 + myProp: PropTypes.shape,
423 + };
424 render() {
425 return React.createElement('span', null, this.props.myProp.value);
426 }
427 }
423 - Component.propTypes = {
424 - myProp: React.PropTypes.shape,
425 - };
428
429 ReactTestUtils.renderIntoDocument(
430 React.createElement(Component, {myProp: {value: 'hi'}}),
src/isomorphic/classic/types/ReactPropTypes.js
+3 -544
@@ -11,548 +11,7 @@
11
12 'use strict';
13
14 -var ReactElement = require('ReactElement');
15 -var ReactPropTypesSecret = require('ReactPropTypesSecret');
14 +var {isValidElement} = require('ReactElement');
15 +var factory = require('prop-types/factory');
16
17 -var emptyFunction = require('fbjs/lib/emptyFunction');
18 -var getIteratorFn = require('getIteratorFn');
19 -var invariant = require('fbjs/lib/invariant');
20 -var warning = require('fbjs/lib/warning');
21 -
22 -/**
23 - * Collection of methods that allow declaration and validation of props that are
24 - * supplied to React components. Example usage:
25 - *
26 - * var Props = require('ReactPropTypes');
27 - * var MyArticle = React.createClass({
28 - * propTypes: {
29 - * // An optional string prop named "description".
30 - * description: Props.string,
31 - *
32 - * // A required enum prop named "category".
33 - * category: Props.oneOf(['News','Photos']).isRequired,
34 - *
35 - * // A prop named "dialog" that requires an instance of Dialog.
36 - * dialog: Props.instanceOf(Dialog).isRequired
37 - * },
38 - * render: function() { ... }
39 - * });
40 - *
41 - * A more formal specification of how these methods are used:
42 - *
43 - * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
44 - * decl := ReactPropTypes.{type}(.isRequired)?
45 - *
46 - * Each and every declaration produces a function with the same signature. This
47 - * allows the creation of custom validation functions. For example:
48 - *
49 - * var MyLink = React.createClass({
50 - * propTypes: {
51 - * // An optional string or URI prop named "href".
52 - * href: function(props, propName, componentName) {
53 - * var propValue = props[propName];
54 - * if (propValue != null && typeof propValue !== 'string' &&
55 - * !(propValue instanceof URI)) {
56 - * return new Error(
57 - * 'Expected a string or an URI for ' + propName + ' in ' +
58 - * componentName
59 - * );
60 - * }
61 - * }
62 - * },
63 - * render: function() {...}
64 - * });
65 - *
66 - * @internal
67 - */
68 -
69 -var ANONYMOUS = '<<anonymous>>';
70 -
71 -var ReactPropTypes;
72 -
73 -if (__DEV__) {
74 - // Keep in sync with production version below
75 - ReactPropTypes = {
76 - array: createPrimitiveTypeChecker('array'),
77 - bool: createPrimitiveTypeChecker('boolean'),
78 - func: createPrimitiveTypeChecker('function'),
79 - number: createPrimitiveTypeChecker('number'),
80 - object: createPrimitiveTypeChecker('object'),
81 - string: createPrimitiveTypeChecker('string'),
82 - symbol: createPrimitiveTypeChecker('symbol'),
83 -
84 - any: createAnyTypeChecker(),
85 - arrayOf: createArrayOfTypeChecker,
86 - element: createElementTypeChecker(),
87 - instanceOf: createInstanceTypeChecker,
88 - node: createNodeChecker(),
89 - objectOf: createObjectOfTypeChecker,
90 - oneOf: createEnumTypeChecker,
91 - oneOfType: createUnionTypeChecker,
92 - shape: createShapeTypeChecker,
93 - };
94 -} else {
95 - var productionTypeChecker = function() {
96 - invariant(
97 - false,
98 - 'React.PropTypes type checking code is stripped in production.',
99 - );
100 - };
101 - productionTypeChecker.isRequired = productionTypeChecker;
102 - var getProductionTypeChecker = () => productionTypeChecker;
103 - // Keep in sync with development version above
104 - ReactPropTypes = {
105 - array: productionTypeChecker,
106 - bool: productionTypeChecker,
107 - func: productionTypeChecker,
108 - number: productionTypeChecker,
109 - object: productionTypeChecker,
110 - string: productionTypeChecker,
111 - symbol: productionTypeChecker,
112 -
113 - any: productionTypeChecker,
114 - arrayOf: getProductionTypeChecker,
115 - element: productionTypeChecker,
116 - instanceOf: getProductionTypeChecker,
117 - node: productionTypeChecker,
118 - objectOf: getProductionTypeChecker,
119 - oneOf: getProductionTypeChecker,
120 - oneOfType: getProductionTypeChecker,
121 - shape: getProductionTypeChecker,
122 - };
123 -}
124 -
125 -/**
126 - * inlined Object.is polyfill to avoid requiring consumers ship their own
127 - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
128 - */
129 -/*eslint-disable no-self-compare*/
130 -function is(x, y) {
131 - // SameValue algorithm
132 - if (x === y) {
133 - // Steps 1-5, 7-10
134 - // Steps 6.b-6.e: +0 != -0
135 - return x !== 0 || 1 / x === 1 / y;
136 - } else {
137 - // Step 6.a: NaN == NaN
138 - return x !== x && y !== y;
139 - }
140 -}
141 -/*eslint-enable no-self-compare*/
142 -
143 -/**
144 - * We use an Error-like object for backward compatibility as people may call
145 - * PropTypes directly and inspect their output. However, we don't use real
146 - * Errors anymore. We don't inspect their stack anyway, and creating them
147 - * is prohibitively expensive if they are created too often, such as what
148 - * happens in oneOfType() for any type before the one that matched.
149 - */
150 -function PropTypeError(message) {
151 - this.message = message;
152 - this.stack = '';
153 -}
154 -// Make `instanceof Error` still work for returned errors.
155 -PropTypeError.prototype = Error.prototype;
156 -
157 -function createChainableTypeChecker(validate) {
158 - if (__DEV__) {
159 - var manualPropTypeCallCache = {};
160 - }
161 - function checkType(
162 - isRequired,
163 - props,
164 - propName,
165 - componentName,
166 - location,
167 - propFullName,
168 - secret,
169 - ) {
170 - componentName = componentName || ANONYMOUS;
171 - propFullName = propFullName || propName;
172 - if (__DEV__) {
173 - if (secret !== ReactPropTypesSecret && typeof console !== 'undefined') {
174 - var cacheKey = `${componentName}:${propName}`;
175 - if (!manualPropTypeCallCache[cacheKey]) {
176 - warning(
177 - false,
178 - 'You are manually calling a React.PropTypes validation ' +
179 - 'function for the `%s` prop on `%s`. This is deprecated ' +
180 - 'and will not work in production with the next major version. ' +
181 - 'You may be seeing this warning due to a third-party PropTypes ' +
182 - 'library. See https://fb.me/react-warning-dont-call-proptypes ' +
183 - 'for details.',
184 - propFullName,
185 - componentName,
186 - );
187 - manualPropTypeCallCache[cacheKey] = true;
188 - }
189 - }
190 - }
191 - if (props[propName] == null) {
192 - if (isRequired) {
193 - if (props[propName] === null) {
194 - return new PropTypeError(
195 - `The ${location} \`${propFullName}\` is marked as required ` +
196 - `in \`${componentName}\`, but its value is \`null\`.`,
197 - );
198 - }
199 - return new PropTypeError(
200 - `The ${location} \`${propFullName}\` is marked as required in ` +
201 - `\`${componentName}\`, but its value is \`undefined\`.`,
202 - );
203 - }
204 - return null;
205 - } else {
206 - return validate(props, propName, componentName, location, propFullName);
207 - }
208 - }
209 -
210 - var chainedCheckType = checkType.bind(null, false);
211 - chainedCheckType.isRequired = checkType.bind(null, true);
212 -
213 - return chainedCheckType;
214 -}
215 -
216 -function createPrimitiveTypeChecker(expectedType) {
217 - function validate(
218 - props,
219 - propName,
220 - componentName,
221 - location,
222 - propFullName,
223 - secret,
224 - ) {
225 - var propValue = props[propName];
226 - var propType = getPropType(propValue);
227 - if (propType !== expectedType) {
228 - // `propValue` being instance of, say, date/regexp, pass the 'object'
229 - // check, but we can offer a more precise error message here rather than
230 - // 'of type `object`'.
231 - var preciseType = getPreciseType(propValue);
232 -
233 - return new PropTypeError(
234 - `Invalid ${location} \`${propFullName}\` of type ` +
235 - `\`${preciseType}\` supplied to \`${componentName}\`, expected ` +
236 - `\`${expectedType}\`.`,
237 - );
238 - }
239 - return null;
240 - }
241 - return createChainableTypeChecker(validate);
242 -}
243 -
244 -function createAnyTypeChecker() {
245 - return createChainableTypeChecker(emptyFunction.thatReturnsNull);
246 -}
247 -
248 -function createArrayOfTypeChecker(typeChecker) {
249 - function validate(props, propName, componentName, location, propFullName) {
250 - if (typeof typeChecker !== 'function') {
251 - return new PropTypeError(
252 - `Property \`${propFullName}\` of component \`${componentName}\` has invalid PropType notation inside arrayOf.`,
253 - );
254 - }
255 - var propValue = props[propName];
256 - if (!Array.isArray(propValue)) {
257 - var propType = getPropType(propValue);
258 - return new PropTypeError(
259 - `Invalid ${location} \`${propFullName}\` of type ` +
260 - `\`${propType}\` supplied to \`${componentName}\`, expected an array.`,
261 - );
262 - }
263 - for (var i = 0; i < propValue.length; i++) {
264 - var error = typeChecker(
265 - propValue,
266 - i,
267 - componentName,
268 - location,
269 - `${propFullName}[${i}]`,
270 - ReactPropTypesSecret,
271 - );
272 - if (error instanceof Error) {
273 - return error;
274 - }
275 - }
276 - return null;
277 - }
278 - return createChainableTypeChecker(validate);
279 -}
280 -
281 -function createElementTypeChecker() {
282 - function validate(props, propName, componentName, location, propFullName) {
283 - var propValue = props[propName];
284 - if (!ReactElement.isValidElement(propValue)) {
285 - var propType = getPropType(propValue);
286 - return new PropTypeError(
287 - `Invalid ${location} \`${propFullName}\` of type ` +
288 - `\`${propType}\` supplied to \`${componentName}\`, expected a single ReactElement.`,
289 - );
290 - }
291 - return null;
292 - }
293 - return createChainableTypeChecker(validate);
294 -}
295 -
296 -function createInstanceTypeChecker(expectedClass) {
297 - function validate(props, propName, componentName, location, propFullName) {
298 - if (!(props[propName] instanceof expectedClass)) {
299 - var expectedClassName = expectedClass.name || ANONYMOUS;
300 - var actualClassName = getClassName(props[propName]);
301 - return new PropTypeError(
302 - `Invalid ${location} \`${propFullName}\` of type ` +
303 - `\`${actualClassName}\` supplied to \`${componentName}\`, expected ` +
304 - `instance of \`${expectedClassName}\`.`,
305 - );
306 - }
307 - return null;
308 - }
309 - return createChainableTypeChecker(validate);
310 -}
311 -
312 -function createEnumTypeChecker(expectedValues) {
313 - if (!Array.isArray(expectedValues)) {
314 - warning(
315 - false,
316 - 'Invalid argument supplied to oneOf, expected an instance of array.',
317 - );
318 - return emptyFunction.thatReturnsNull;
319 - }
320 -
321 - function validate(props, propName, componentName, location, propFullName) {
322 - var propValue = props[propName];
323 - for (var i = 0; i < expectedValues.length; i++) {
324 - if (is(propValue, expectedValues[i])) {
325 - return null;
326 - }
327 - }
328 -
329 - var valuesString = JSON.stringify(expectedValues);
330 - return new PropTypeError(
331 - `Invalid ${location} \`${propFullName}\` of value \`${propValue}\` ` +
332 - `supplied to \`${componentName}\`, expected one of ${valuesString}.`,
333 - );
334 - }
335 - return createChainableTypeChecker(validate);
336 -}
337 -
338 -function createObjectOfTypeChecker(typeChecker) {
339 - function validate(props, propName, componentName, location, propFullName) {
340 - if (typeof typeChecker !== 'function') {
341 - return new PropTypeError(
342 - `Property \`${propFullName}\` of component \`${componentName}\` has invalid PropType notation inside objectOf.`,
343 - );
344 - }
345 - var propValue = props[propName];
346 - var propType = getPropType(propValue);
347 - if (propType !== 'object') {
348 - return new PropTypeError(
349 - `Invalid ${location} \`${propFullName}\` of type ` +
350 - `\`${propType}\` supplied to \`${componentName}\`, expected an object.`,
351 - );
352 - }
353 - for (var key in propValue) {
354 - if (propValue.hasOwnProperty(key)) {
355 - var error = typeChecker(
356 - propValue,
357 - key,
358 - componentName,
359 - location,
360 - `${propFullName}.${key}`,
361 - ReactPropTypesSecret,
362 - );
363 - if (error instanceof Error) {
364 - return error;
365 - }
366 - }
367 - }
368 - return null;
369 - }
370 - return createChainableTypeChecker(validate);
371 -}
372 -
373 -function createUnionTypeChecker(arrayOfTypeCheckers) {
374 - if (!Array.isArray(arrayOfTypeCheckers)) {
375 - warning(
376 - false,
377 - 'Invalid argument supplied to oneOfType, expected an instance of array.',
378 - );
379 - return emptyFunction.thatReturnsNull;
380 - }
381 -
382 - function validate(props, propName, componentName, location, propFullName) {
383 - for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
384 - var checker = arrayOfTypeCheckers[i];
385 - if (
386 - checker(
387 - props,
388 - propName,
389 - componentName,
390 - location,
391 - propFullName,
392 - ReactPropTypesSecret,
393 - ) == null
394 - ) {
395 - return null;
396 - }
397 - }
398 -
399 - return new PropTypeError(
400 - `Invalid ${location} \`${propFullName}\` supplied to ` +
401 - `\`${componentName}\`.`,
402 - );
403 - }
404 - return createChainableTypeChecker(validate);
405 -}
406 -
407 -function createNodeChecker() {
408 - function validate(props, propName, componentName, location, propFullName) {
409 - if (!isNode(props[propName])) {
410 - return new PropTypeError(
411 - `Invalid ${location} \`${propFullName}\` supplied to ` +
412 - `\`${componentName}\`, expected a ReactNode.`,
413 - );
414 - }
415 - return null;
416 - }
417 - return createChainableTypeChecker(validate);
418 -}
419 -
420 -function createShapeTypeChecker(shapeTypes) {
421 - function validate(props, propName, componentName, location, propFullName) {
422 - var propValue = props[propName];
423 - var propType = getPropType(propValue);
424 - if (propType !== 'object') {
425 - return new PropTypeError(
426 - `Invalid ${location} \`${propFullName}\` of type \`${propType}\` ` +
427 - `supplied to \`${componentName}\`, expected \`object\`.`,
428 - );
429 - }
430 - for (var key in shapeTypes) {
431 - var checker = shapeTypes[key];
432 - if (!checker) {
433 - continue;
434 - }
435 - var error = checker(
436 - propValue,
437 - key,
438 - componentName,
439 - location,
440 - `${propFullName}.${key}`,
441 - ReactPropTypesSecret,
442 - );
443 - if (error) {
444 - return error;
445 - }
446 - }
447 - return null;
448 - }
449 - return createChainableTypeChecker(validate);
450 -}
451 -
452 -function isNode(propValue) {
453 - switch (typeof propValue) {
454 - case 'number':
455 - case 'string':
456 - case 'undefined':
457 - return true;
458 - case 'boolean':
459 - return !propValue;
460 - case 'object':
461 - if (Array.isArray(propValue)) {
462 - return propValue.every(isNode);
463 - }
464 - if (propValue === null || ReactElement.isValidElement(propValue)) {
465 - return true;
466 - }
467 -
468 - var iteratorFn = getIteratorFn(propValue);
469 - if (iteratorFn) {
470 - var iterator = iteratorFn.call(propValue);
471 - var step;
472 - if (iteratorFn !== propValue.entries) {
473 - while (!(step = iterator.next()).done) {
474 - if (!isNode(step.value)) {
475 - return false;
476 - }
477 - }
478 - } else {
479 - // Iterator will provide entry [k,v] tuples rather than values.
480 - while (!(step = iterator.next()).done) {
481 - var entry = step.value;
482 - if (entry) {
483 - if (!isNode(entry[1])) {
484 - return false;
485 - }
486 - }
487 - }
488 - }
489 - } else {
490 - return false;
491 - }
492 -
493 - return true;
494 - default:
495 - return false;
496 - }
497 -}
498 -
499 -function isSymbol(propType, propValue) {
500 - // Native Symbol.
501 - if (propType === 'symbol') {
502 - return true;
503 - }
504 -
505 - // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
506 - if (propValue['@@toStringTag'] === 'Symbol') {
507 - return true;
508 - }
509 -
510 - // Fallback for non-spec compliant Symbols which are polyfilled.
511 - if (typeof Symbol === 'function' && propValue instanceof Symbol) {
512 - return true;
513 - }
514 -
515 - return false;
516 -}
517 -
518 -// Equivalent of `typeof` but with special handling for array and regexp.
519 -function getPropType(propValue) {
520 - var propType = typeof propValue;
521 - if (Array.isArray(propValue)) {
522 - return 'array';
523 - }
524 - if (propValue instanceof RegExp) {
525 - // Old webkits (at least until Android 4.0) return 'function' rather than
526 - // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
527 - // passes PropTypes.object.
528 - return 'object';
529 - }
530 - if (isSymbol(propType, propValue)) {
531 - return 'symbol';
532 - }
533 - return propType;
534 -}
535 -
536 -// This handles more types than `getPropType`. Only used for error messages.
537 -// See `createPrimitiveTypeChecker`.
538 -function getPreciseType(propValue) {
539 - var propType = getPropType(propValue);
540 - if (propType === 'object') {
541 - if (propValue instanceof Date) {
542 - return 'date';
543 - } else if (propValue instanceof RegExp) {
544 - return 'regexp';
545 - }
546 - }
547 - return propType;
548 -}
549 -
550 -// Returns class name of the object, if any.
551 -function getClassName(propValue) {
552 - if (!propValue.constructor || !propValue.constructor.name) {
553 - return ANONYMOUS;
554 - }
555 - return propValue.constructor.name;
556 -}
557 -
558 -module.exports = ReactPropTypes;
17 +module.exports = factory(isValidElement);
src/isomorphic/classic/types/__tests__/ReactPropTypesProduction-test.js deleted
-219
@@ -1,219 +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('ReactPropTypesProduction', function() {
15 - var PropTypes;
16 - var React;
17 - var ReactTestUtils;
18 - var oldProcess;
19 -
20 - beforeEach(function() {
21 - __DEV__ = false;
22 -
23 - // Mutating process.env.NODE_ENV would cause our babel plugins to do the
24 - // wrong thing. If you change this, make sure to test with jest --no-cache.
25 - oldProcess = process;
26 - global.process = {
27 - ...process,
28 - env: {...process.env, NODE_ENV: 'production'},
29 - };
30 -
31 - jest.resetModules();
32 - PropTypes = require('ReactPropTypes');
33 - React = require('react');
34 - ReactTestUtils = require('ReactTestUtils');
35 - });
36 -
37 - afterEach(function() {
38 - __DEV__ = true;
39 - global.process = oldProcess;
40 - });
41 -
42 - function expectThrowsInProduction(declaration, value) {
43 - var props = {testProp: value};
44 - expect(() => {
45 - declaration(props, 'testProp', 'testComponent', 'prop');
46 - }).toThrowError('Minified React error #144');
47 - }
48 -
49 - describe('Primitive Types', function() {
50 - it('should be a no-op', function() {
51 - expectThrowsInProduction(PropTypes.array, /please/);
52 - expectThrowsInProduction(PropTypes.array.isRequired, /please/);
53 - expectThrowsInProduction(PropTypes.array.isRequired, null);
54 - expectThrowsInProduction(PropTypes.array.isRequired, undefined);
55 - expectThrowsInProduction(PropTypes.bool, []);
56 - expectThrowsInProduction(PropTypes.bool.isRequired, []);
57 - expectThrowsInProduction(PropTypes.bool.isRequired, null);
58 - expectThrowsInProduction(PropTypes.bool.isRequired, undefined);
59 - expectThrowsInProduction(PropTypes.func, false);
60 - expectThrowsInProduction(PropTypes.func.isRequired, false);
61 - expectThrowsInProduction(PropTypes.func.isRequired, null);
62 - expectThrowsInProduction(PropTypes.func.isRequired, undefined);
63 - expectThrowsInProduction(PropTypes.number, function() {});
64 - expectThrowsInProduction(PropTypes.number.isRequired, function() {});
65 - expectThrowsInProduction(PropTypes.number.isRequired, null);
66 - expectThrowsInProduction(PropTypes.number.isRequired, undefined);
67 - expectThrowsInProduction(PropTypes.string, 0);
68 - expectThrowsInProduction(PropTypes.string.isRequired, 0);
69 - expectThrowsInProduction(PropTypes.string.isRequired, null);
70 - expectThrowsInProduction(PropTypes.string.isRequired, undefined);
71 - expectThrowsInProduction(PropTypes.symbol, 0);
72 - expectThrowsInProduction(PropTypes.symbol.isRequired, 0);
73 - expectThrowsInProduction(PropTypes.symbol.isRequired, null);
74 - expectThrowsInProduction(PropTypes.symbol.isRequired, undefined);
75 - expectThrowsInProduction(PropTypes.object, '');
76 - expectThrowsInProduction(PropTypes.object.isRequired, '');
77 - expectThrowsInProduction(PropTypes.object.isRequired, null);
78 - expectThrowsInProduction(PropTypes.object.isRequired, undefined);
79 - });
80 - });
81 -
82 - describe('Any Type', function() {
83 - it('should be a no-op', function() {
84 - expectThrowsInProduction(PropTypes.any, null);
85 - expectThrowsInProduction(PropTypes.any.isRequired, null);
86 - expectThrowsInProduction(PropTypes.any.isRequired, undefined);
87 - });
88 - });
89 -
90 - describe('ArrayOf Type', function() {
91 - it('should be a no-op', function() {
92 - expectThrowsInProduction(PropTypes.arrayOf({foo: PropTypes.string}), {
93 - foo: 'bar',
94 - });
95 - expectThrowsInProduction(PropTypes.arrayOf(PropTypes.number), [
96 - 1,
97 - 2,
98 - 'b',
99 - ]);
100 - expectThrowsInProduction(PropTypes.arrayOf(PropTypes.number), {
101 - '0': 'maybe-array',
102 - length: 1,
103 - });
104 - expectThrowsInProduction(
105 - PropTypes.arrayOf(PropTypes.number).isRequired,
106 - null,
107 - );
108 - expectThrowsInProduction(
109 - PropTypes.arrayOf(PropTypes.number).isRequired,
110 - undefined,
111 - );
112 - });
113 - });
114 -
115 - describe('Component Type', function() {
116 - it('should be a no-op', function() {
117 - expectThrowsInProduction(PropTypes.element, [<div />, <div />]);
118 - expectThrowsInProduction(PropTypes.element, 123);
119 - expectThrowsInProduction(PropTypes.element, 'foo');
120 - expectThrowsInProduction(PropTypes.element, false);
121 - expectThrowsInProduction(PropTypes.element.isRequired, null);
122 - expectThrowsInProduction(PropTypes.element.isRequired, undefined);
123 - });
124 - });
125 -
126 - describe('Instance Types', function() {
127 - it('should be a no-op', function() {
128 - expectThrowsInProduction(PropTypes.instanceOf(Date), {});
129 - expectThrowsInProduction(PropTypes.instanceOf(Date).isRequired, {});
130 - });
131 - });
132 -
133 - describe('React Component Types', function() {
134 - it('should be a no-op', function() {
135 - expectThrowsInProduction(PropTypes.node, {});
136 - expectThrowsInProduction(PropTypes.node.isRequired, null);
137 - expectThrowsInProduction(PropTypes.node.isRequired, undefined);
138 - });
139 - });
140 -
141 - describe('ObjectOf Type', function() {
142 - it('should be a no-op', function() {
143 - expectThrowsInProduction(PropTypes.objectOf({foo: PropTypes.string}), {
144 - foo: 'bar',
145 - });
146 - expectThrowsInProduction(PropTypes.objectOf(PropTypes.number), {
147 - a: 1,
148 - b: 2,
149 - c: 'b',
150 - });
151 - expectThrowsInProduction(PropTypes.objectOf(PropTypes.number), [1, 2]);
152 - expectThrowsInProduction(PropTypes.objectOf(PropTypes.number), null);
153 - expectThrowsInProduction(PropTypes.objectOf(PropTypes.number), undefined);
154 - });
155 - });
156 -
157 - describe('OneOf Types', function() {
158 - it('should be a no-op', function() {
159 - expectThrowsInProduction(PropTypes.oneOf('red', 'blue'), 'red');
160 - expectThrowsInProduction(PropTypes.oneOf(['red', 'blue']), true);
161 - expectThrowsInProduction(PropTypes.oneOf(['red', 'blue']), null);
162 - expectThrowsInProduction(PropTypes.oneOf(['red', 'blue']), undefined);
163 - });
164 - });
165 -
166 - describe('Union Types', function() {
167 - it('should be a no-op', function() {
168 - expectThrowsInProduction(
169 - PropTypes.oneOfType(PropTypes.string, PropTypes.number),
170 - 'red',
171 - );
172 - expectThrowsInProduction(
173 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
174 - [],
175 - );
176 - expectThrowsInProduction(
177 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
178 - null,
179 - );
180 - expectThrowsInProduction(
181 - PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
182 - undefined,
183 - );
184 - });
185 - });
186 -
187 - describe('Shape Types', function() {
188 - it('should be a no-op', function() {
189 - expectThrowsInProduction(PropTypes.shape({}), 'some string');
190 - expectThrowsInProduction(
191 - PropTypes.shape({key: PropTypes.number}).isRequired,
192 - null,
193 - );
194 - expectThrowsInProduction(
195 - PropTypes.shape({key: PropTypes.number}).isRequired,
196 - undefined,
197 - );
198 - });
199 - });
200 -
201 - describe('Custom validator', function() {
202 - beforeEach(function() {
203 - jest.resetModules();
204 - });
205 -
206 - it('should not have been called', function() {
207 - var spy = jest.fn();
208 - function Component() {
209 - return <div />;
210 - }
211 - Component.propTypes = {num: spy};
212 -
213 - var instance = <Component num={5} />;
214 - ReactTestUtils.renderIntoDocument(instance);
215 -
216 - expect(spy).not.toBeCalled();
217 - });
218 - });
219 -});
src/isomorphic/classic/types/checkPropTypes.js
+1 -81
@@ -11,84 +11,4 @@
11
12 'use strict';
13
14 -var ReactPropTypesSecret = require('ReactPropTypesSecret');
15 -
16 -var invariant = require('fbjs/lib/invariant');
17 -var warning = require('fbjs/lib/warning');
18 -
19 -var loggedTypeFailures = {};
20 -
21 -/**
22 - * Assert that the values match with the type specs.
23 - * Error messages are memorized and will only be shown once.
24 - *
25 - * @param {object} typeSpecs Map of name to a ReactPropType
26 - * @param {object} values Runtime values that need to be type-checked
27 - * @param {string} location e.g. "prop", "context", "child context"
28 - * @param {string} componentName Name of the component for error messages.
29 - * @param {?Function} getStack Returns the component stack.
30 - * @private
31 - */
32 -function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
33 - if (__DEV__) {
34 - for (var typeSpecName in typeSpecs) {
35 - if (typeSpecs.hasOwnProperty(typeSpecName)) {
36 - var error;
37 - // Prop type validation may throw. In case they do, we don't want to
38 - // fail the render phase where it didn't fail before. So we log it.
39 - // After these have been cleaned up, we'll let them throw.
40 - try {
41 - // This is intentionally an invariant that gets caught. It's the same
42 - // behavior as without this statement except with a better message.
43 - invariant(
44 - typeof typeSpecs[typeSpecName] === 'function',
45 - '%s: %s type `%s` is invalid; it must be a function, usually from ' +
46 - 'React.PropTypes.',
47 - componentName || 'React class',
48 - location,
49 - typeSpecName,
50 - );
51 - error = typeSpecs[typeSpecName](
52 - values,
53 - typeSpecName,
54 - componentName,
55 - location,
56 - null,
57 - ReactPropTypesSecret,
58 - );
59 - } catch (ex) {
60 - error = ex;
61 - }
62 - warning(
63 - !error || error instanceof Error,
64 - '%s: type specification of %s `%s` is invalid; the type checker ' +
65 - 'function must return `null` or an `Error` but returned a %s. ' +
66 - 'You may have forgotten to pass an argument to the type checker ' +
67 - 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
68 - 'shape all require an argument).',
69 - componentName || 'React class',
70 - location,
71 - typeSpecName,
72 - typeof error,
73 - );
74 - if (error instanceof Error && !(error.message in loggedTypeFailures)) {
75 - // Only monitor this failure once because there tends to be a lot of the
76 - // same error.
77 - loggedTypeFailures[error.message] = true;
78 -
79 - var stack = getStack ? getStack() : '';
80 -
81 - warning(
82 - false,
83 - 'Failed %s type: %s%s',
84 - location,
85 - error.message,
86 - stack != null ? stack : '',
87 - );
88 - }
89 - }
90 - }
91 - }
92 -}
93 -
94 -module.exports = checkPropTypes;
14 +module.exports = require('prop-types/checkPropTypes');
src/isomorphic/modern/class/PropTypes.d.ts new
+19
@@ -0,0 +1,19 @@
1 +/*!
2 + * Copyright 2015-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 +
10 +/**
11 + * TypeScript Definition File for React.
12 + *
13 + * Full type definitions are not yet officially supported. These are mostly
14 + * just helpers for the unit test.
15 + */
16 +
17 +declare module 'prop-types' {
18 + export var string : any;
19 +}
src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee
+8 -6
@@ -9,6 +9,7 @@ of patent rights can be found in the PATENTS file in the same directory.
9
10 React = null
11 ReactDOM = null
12 +PropTypes = null
13
14 describe 'ReactCoffeeScriptClass', ->
15 div = null
@@ -21,6 +22,7 @@ describe 'ReactCoffeeScriptClass', ->
22 beforeEach ->
23 React = require 'react'
24 ReactDOM = require 'react-dom'
25 + PropTypes = require 'prop-types'
26 container = document.createElement 'div'
27 attachedListener = null
28 renderedName = null
@@ -102,8 +104,8 @@ describe 'ReactCoffeeScriptClass', ->
104 it 'renders based on context in the constructor', ->
105 class Foo extends React.Component
106 @contextTypes:
105 - tag: React.PropTypes.string
106 - className: React.PropTypes.string
107 + tag: PropTypes.string
108 + className: PropTypes.string
109
110 constructor: (props, context) ->
111 super props, context
@@ -118,8 +120,8 @@ describe 'ReactCoffeeScriptClass', ->
120
121 class Outer extends React.Component
122 @childContextTypes:
121 - tag: React.PropTypes.string
122 - className: React.PropTypes.string
123 + tag: PropTypes.string
124 + className: PropTypes.string
125
126 getChildContext: ->
127 tag: 'span'
@@ -393,13 +395,13 @@ describe 'ReactCoffeeScriptClass', ->
395 it 'supports this.context passed via getChildContext', ->
396 class Bar extends React.Component
397 @contextTypes:
396 - bar: React.PropTypes.string
398 + bar: PropTypes.string
399 render: ->
400 div className: @context.bar
401
402 class Foo extends React.Component
403 @childContextTypes:
402 - bar: React.PropTypes.string
404 + bar: PropTypes.string
405 getChildContext: ->
406 bar: 'bar-through-context'
407 render: ->
src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
+8 -6
@@ -11,6 +11,7 @@
11
12 'use strict';
13
14 +var PropTypes;
15 var React;
16 var ReactDOM;
17
@@ -25,6 +26,7 @@ describe('ReactES6Class', () => {
26 var renderedName = null;
27
28 beforeEach(() => {
29 + PropTypes = require('prop-types');
30 React = require('react');
31 ReactDOM = require('react-dom');
32 container = document.createElement('div');
@@ -123,8 +125,8 @@ describe('ReactES6Class', () => {
125 }
126 }
127 Foo.contextTypes = {
126 - tag: React.PropTypes.string,
127 - className: React.PropTypes.string,
128 + tag: PropTypes.string,
129 + className: PropTypes.string,
130 };
131
132 class Outer extends React.Component {
@@ -136,8 +138,8 @@ describe('ReactES6Class', () => {
138 }
139 }
140 Outer.childContextTypes = {
139 - tag: React.PropTypes.string,
140 - className: React.PropTypes.string,
141 + tag: PropTypes.string,
142 + className: PropTypes.string,
143 };
144 test(<Outer />, 'SPAN', 'foo');
145 });
@@ -419,7 +421,7 @@ describe('ReactES6Class', () => {
421 return <div className={this.context.bar} />;
422 }
423 }
422 - Bar.contextTypes = {bar: React.PropTypes.string};
424 + Bar.contextTypes = {bar: PropTypes.string};
425 class Foo extends React.Component {
426 getChildContext() {
427 return {bar: 'bar-through-context'};
@@ -428,7 +430,7 @@ describe('ReactES6Class', () => {
430 return <Bar />;
431 }
432 }
431 - Foo.childContextTypes = {bar: React.PropTypes.string};
433 + Foo.childContextTypes = {bar: PropTypes.string};
434 test(<Foo />, 'DIV', 'bar-through-context');
435 });
436
src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts
+8 -6
@@ -1,3 +1,4 @@
1 +/// <reference path="../PropTypes.d.ts" />
2 /// <reference path="../React.d.ts" />
3 /// <reference path="../ReactDOM.d.ts" />
4
@@ -12,6 +13,7 @@
13
14 import React = require('react');
15 import ReactDOM = require('react-dom');
16 +import PropTypes = require('prop-types');
17
18 // Before Each
19
@@ -85,8 +87,8 @@ class StateBasedOnProps extends React.Component {
87 // it renders based on context in the constructor
88 class StateBasedOnContext extends React.Component {
89 static contextTypes = {
88 - tag: React.PropTypes.string,
89 - className: React.PropTypes.string
90 + tag: PropTypes.string,
91 + className: PropTypes.string
92 };
93 state = {
94 tag: this.context.tag,
@@ -100,8 +102,8 @@ class StateBasedOnContext extends React.Component {
102
103 class ProvideChildContextTypes extends React.Component {
104 static childContextTypes = {
103 - tag: React.PropTypes.string,
104 - className: React.PropTypes.string
105 + tag: PropTypes.string,
106 + className: PropTypes.string
107 };
108 getChildContext() {
109 return { tag: 'span', className: 'foo' };
@@ -278,13 +280,13 @@ class MisspelledComponent2 extends React.Component {
280
281 // it supports this.context passed via getChildContext
282 class ReadContext extends React.Component {
281 - static contextTypes = { bar: React.PropTypes.string };
283 + static contextTypes = { bar: PropTypes.string };
284 render() {
285 return React.createElement('div', { className: this.context.bar });
286 }
287 }
288 class ProvideContext extends React.Component {
287 - static childContextTypes = { bar: React.PropTypes.string };
289 + static childContextTypes = { bar: PropTypes.string };
290 getChildContext() {
291 return { bar: 'bar-through-context' };
292 }
src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
+5 -3
@@ -17,6 +17,7 @@
17 var React;
18 var ReactDOM;
19 var ReactTestUtils;
20 +var PropTypes;
21
22 describe('ReactJSXElementValidator', () => {
23 function normalizeCodeLocInfo(str) {
@@ -29,6 +30,7 @@ describe('ReactJSXElementValidator', () => {
30 beforeEach(() => {
31 jest.resetModules();
32
33 + PropTypes = require('prop-types');
34 React = require('react');
35 ReactDOM = require('react-dom');
36 ReactTestUtils = require('ReactTestUtils');
@@ -45,7 +47,7 @@ describe('ReactJSXElementValidator', () => {
47 }
48 };
49 RequiredPropComponent.displayName = 'RequiredPropComponent';
48 - RequiredPropComponent.propTypes = {prop: React.PropTypes.string.isRequired};
50 + RequiredPropComponent.propTypes = {prop: PropTypes.string.isRequired};
51 });
52
53 it('warns for keys for arrays of elements in children position', () => {
@@ -188,7 +190,7 @@ describe('ReactJSXElementValidator', () => {
190 }
191 }
192 MyComp.propTypes = {
191 - color: React.PropTypes.string,
193 + color: PropTypes.string,
194 };
195 class ParentComp extends React.Component {
196 render() {
@@ -211,7 +213,7 @@ describe('ReactJSXElementValidator', () => {
213 return null;
214 }
215 MyComp.propTypes = {
214 - color: React.PropTypes.string,
216 + color: PropTypes.string,
217 };
218 function MiddleComp(props) {
219 return <MyComp color={props.color} />;
src/renderers/__tests__/ReactComponentLifeCycle-test.js
+4 -2
@@ -14,6 +14,7 @@
14 var React;
15 var ReactDOM;
16 var ReactTestUtils;
17 +var PropTypes;
18
19 var clone = function(o) {
20 return JSON.parse(JSON.stringify(o));
@@ -91,6 +92,7 @@ describe('ReactComponentLifeCycle', () => {
92 React = require('react');
93 ReactDOM = require('react-dom');
94 ReactTestUtils = require('ReactTestUtils');
95 + PropTypes = require('prop-types');
96 });
97
98 it('should not reuse an instance when it has been unmounted', () => {
@@ -605,14 +607,14 @@ describe('ReactComponentLifeCycle', () => {
607 };
608 }
609 Parent.childContextTypes = {
608 - x: React.PropTypes.number,
610 + x: PropTypes.number,
611 };
612 function Child(props, context) {
613 expect(context.x).toBe(2);
614 return <div />;
615 }
616 Child.contextTypes = {
615 - x: React.PropTypes.number,
617 + x: PropTypes.number,
618 };
619
620 const div = document.createElement('div');
src/renderers/__tests__/ReactComponentTreeHook-test.native.js
+3 -1
@@ -29,10 +29,12 @@ describeStack('ReactComponentTreeHook', () => {
29 var View;
30 var Image;
31 var Text;
32 + var PropTypes;
33
34 beforeEach(() => {
35 jest.resetModules();
36
37 + PropTypes = require('prop-types');
38 React = require('react');
39 ReactNative = require('ReactNative');
40 ReactInstanceMap = require('ReactInstanceMap');
@@ -50,7 +52,7 @@ describeStack('ReactComponentTreeHook', () => {
52 });
53 Text = class extends React.Component {
54 static childContextTypes = {
53 - isInAParentText: React.PropTypes.bool,
55 + isInAParentText: PropTypes.bool,
56 };
57
58 getChildContext() {
src/renderers/__tests__/ReactErrorBoundaries-test.js
+4 -2
@@ -13,6 +13,7 @@
13
14 var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
15
16 +var PropTypes;
17 var React;
18 var ReactDOM;
19
@@ -37,6 +38,7 @@ describe('ReactErrorBoundaries', () => {
38 var Normal;
39
40 beforeEach(() => {
41 + PropTypes = require('prop-types');
42 ReactDOM = require('react-dom');
43 React = require('react');
44
@@ -737,7 +739,7 @@ describe('ReactErrorBoundaries', () => {
739
740 it('renders an error state if context provider throws in componentWillMount', () => {
741 class BrokenComponentWillMountWithContext extends React.Component {
740 - static childContextTypes = {foo: React.PropTypes.number};
742 + static childContextTypes = {foo: PropTypes.number};
743 getChildContext() {
744 return {foo: 42};
745 }
@@ -774,7 +776,7 @@ describe('ReactErrorBoundaries', () => {
776 };
777 }
778 BrokenComponentWillMountWithContext.childContextTypes = {
777 - foo: React.PropTypes.number,
779 + foo: PropTypes.number,
780 };
781
782 var container = document.createElement('div');
src/renderers/__tests__/ReactStatelessComponent-test.js
+8 -6
@@ -11,6 +11,7 @@
11
12 'use strict';
13
14 +var PropTypes;
15 var React;
16 var ReactDOM;
17 var ReactTestUtils;
@@ -28,6 +29,7 @@ describe('ReactStatelessComponent', () => {
29
30 beforeEach(() => {
31 jest.resetModuleRegistry();
32 + PropTypes = require('prop-types');
33 React = require('react');
34 ReactDOM = require('react-dom');
35 ReactTestUtils = require('ReactTestUtils');
@@ -68,7 +70,7 @@ describe('ReactStatelessComponent', () => {
70 it('should pass context thru stateless component', () => {
71 class Child extends React.Component {
72 static contextTypes = {
71 - test: React.PropTypes.string.isRequired,
73 + test: PropTypes.string.isRequired,
74 };
75
76 render() {
@@ -82,7 +84,7 @@ describe('ReactStatelessComponent', () => {
84
85 class GrandParent extends React.Component {
86 static childContextTypes = {
85 - test: React.PropTypes.string.isRequired,
87 + test: PropTypes.string.isRequired,
88 };
89
90 getChildContext() {
@@ -111,7 +113,7 @@ describe('ReactStatelessComponent', () => {
113 }
114
115 StatelessComponentWithChildContext.childContextTypes = {
114 - foo: React.PropTypes.string,
116 + foo: PropTypes.string,
117 };
118
119 var container = document.createElement('div');
@@ -355,7 +357,7 @@ describe('ReactStatelessComponent', () => {
357 return <div>{props.test}</div>;
358 }
359 Child.defaultProps = {test: 2};
358 - Child.propTypes = {test: React.PropTypes.string};
360 + Child.propTypes = {test: PropTypes.string};
361
362 spyOn(console, 'error');
363 ReactTestUtils.renderIntoDocument(<Child />);
@@ -372,7 +374,7 @@ describe('ReactStatelessComponent', () => {
374 it('should receive context', () => {
375 class Parent extends React.Component {
376 static childContextTypes = {
375 - lang: React.PropTypes.string,
377 + lang: PropTypes.string,
378 };
379
380 getChildContext() {
@@ -387,7 +389,7 @@ describe('ReactStatelessComponent', () => {
389 function Child(props, context) {
390 return <div>{context.lang}</div>;
391 }
390 - Child.contextTypes = {lang: React.PropTypes.string};
392 + Child.contextTypes = {lang: PropTypes.string};
393
394 var el = document.createElement('div');
395 ReactDOM.render(<Parent />, el);
src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
+11 -10
@@ -15,6 +15,7 @@ var React = require('react');
15 var ReactDOM = require('react-dom');
16 var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
17 var ReactTestUtils = require('ReactTestUtils');
18 +var PropTypes = require('prop-types');
19
20 describe('ReactDOMFiber', () => {
21 var container;
@@ -683,7 +684,7 @@ describe('ReactDOMFiber', () => {
684
685 class Component extends React.Component {
686 static contextTypes = {
686 - foo: React.PropTypes.string.isRequired,
687 + foo: PropTypes.string.isRequired,
688 };
689
690 render() {
@@ -693,7 +694,7 @@ describe('ReactDOMFiber', () => {
694
695 class Parent extends React.Component {
696 static childContextTypes = {
696 - foo: React.PropTypes.string.isRequired,
697 + foo: PropTypes.string.isRequired,
698 };
699
700 getChildContext() {
@@ -717,8 +718,8 @@ describe('ReactDOMFiber', () => {
718
719 class Component extends React.Component {
720 static contextTypes = {
720 - foo: React.PropTypes.string.isRequired,
721 - getFoo: React.PropTypes.func.isRequired,
721 + foo: PropTypes.string.isRequired,
722 + getFoo: PropTypes.func.isRequired,
723 };
724
725 render() {
@@ -728,8 +729,8 @@ describe('ReactDOMFiber', () => {
729
730 class Parent extends React.Component {
731 static childContextTypes = {
731 - foo: React.PropTypes.string.isRequired,
732 - getFoo: React.PropTypes.func.isRequired,
732 + foo: PropTypes.string.isRequired,
733 + getFoo: PropTypes.func.isRequired,
734 };
735
736 state = {
@@ -761,8 +762,8 @@ describe('ReactDOMFiber', () => {
762
763 class Component extends React.Component {
764 static contextTypes = {
764 - foo: React.PropTypes.string.isRequired,
765 - getFoo: React.PropTypes.func.isRequired,
765 + foo: PropTypes.string.isRequired,
766 + getFoo: PropTypes.func.isRequired,
767 };
768
769 render() {
@@ -772,8 +773,8 @@ describe('ReactDOMFiber', () => {
773
774 class Parent extends React.Component {
775 static childContextTypes = {
775 - foo: React.PropTypes.string.isRequired,
776 - getFoo: React.PropTypes.func.isRequired,
776 + foo: PropTypes.string.isRequired,
777 + getFoo: PropTypes.func.isRequired,
778 };
779
780 getChildContext() {
src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
+16 -14
@@ -12,6 +12,7 @@
12 'use strict';
13
14 let ExecutionEnvironment;
15 +let PropTypes;
16 let React;
17 let ReactDOM;
18 let ReactDOMServer;
@@ -206,6 +207,7 @@ function expectMarkupMismatch(serverElement, clientElement) {
207 // To get around this, we must reload React modules in between server and client render.
208 function resetModules() {
209 jest.resetModuleRegistry();
210 + PropTypes = require('prop-types');
211 React = require('React');
212 ReactDOM = require('ReactDOM');
213 ReactDOMServer = require('ReactDOMServer');
@@ -1585,7 +1587,7 @@ describe('ReactDOMServerIntegration', () => {
1587 return this.props.children;
1588 }
1589 }
1588 - Parent.childContextTypes = {text: React.PropTypes.string};
1590 + Parent.childContextTypes = {text: PropTypes.string};
1591
1592 PurpleContext = props => <Parent text="purple">{props.children}</Parent>;
1593 RedContext = props => <Parent text="red">{props.children}</Parent>;
@@ -1597,7 +1599,7 @@ describe('ReactDOMServerIntegration', () => {
1599 return <div>{this.context.text}</div>;
1600 }
1601 }
1600 - ClassChildWithContext.contextTypes = {text: React.PropTypes.string};
1602 + ClassChildWithContext.contextTypes = {text: PropTypes.string};
1603
1604 const e = await render(
1605 <PurpleContext><ClassChildWithContext /></PurpleContext>,
@@ -1609,7 +1611,7 @@ describe('ReactDOMServerIntegration', () => {
1611 function StatelessChildWithContext(props, context) {
1612 return <div>{context.text}</div>;
1613 }
1612 - StatelessChildWithContext.contextTypes = {text: React.PropTypes.string};
1614 + StatelessChildWithContext.contextTypes = {text: PropTypes.string};
1615
1616 const e = await render(
1617 <PurpleContext><StatelessChildWithContext /></PurpleContext>,
@@ -1650,7 +1652,7 @@ describe('ReactDOMServerIntegration', () => {
1652 return <div id="classWrongChild">{this.context.text}</div>;
1653 }
1654 }
1653 - ClassChildWithWrongContext.contextTypes = {foo: React.PropTypes.string};
1655 + ClassChildWithWrongContext.contextTypes = {foo: PropTypes.string};
1656
1657 const e = await render(
1658 <PurpleContext><ClassChildWithWrongContext /></PurpleContext>,
@@ -1664,7 +1666,7 @@ describe('ReactDOMServerIntegration', () => {
1666 return <div id="statelessWrongChild">{context.text}</div>;
1667 }
1668 StatelessChildWithWrongContext.contextTypes = {
1667 - foo: React.PropTypes.string,
1669 + foo: PropTypes.string,
1670 };
1671
1672 const e = await render(
@@ -1677,7 +1679,7 @@ describe('ReactDOMServerIntegration', () => {
1679 function Grandchild(props, context) {
1680 return <div>{context.text}</div>;
1681 }
1680 - Grandchild.contextTypes = {text: React.PropTypes.string};
1682 + Grandchild.contextTypes = {text: PropTypes.string};
1683
1684 const Child = props => <Grandchild />;
1685
@@ -1689,7 +1691,7 @@ describe('ReactDOMServerIntegration', () => {
1691 const Grandchild = (props, context) => {
1692 return <div>{context.text}</div>;
1693 };
1692 - Grandchild.contextTypes = {text: React.PropTypes.string};
1694 + Grandchild.contextTypes = {text: PropTypes.string};
1695
1696 const e = await render(
1697 <PurpleContext><RedContext><Grandchild /></RedContext></PurpleContext>,
@@ -1706,7 +1708,7 @@ describe('ReactDOMServerIntegration', () => {
1708 return <Child />;
1709 }
1710 }
1709 - Parent.childContextTypes = {text1: React.PropTypes.string};
1711 + Parent.childContextTypes = {text1: PropTypes.string};
1712
1713 class Child extends React.Component {
1714 getChildContext() {
@@ -1716,7 +1718,7 @@ describe('ReactDOMServerIntegration', () => {
1718 return <Grandchild />;
1719 }
1720 }
1719 - Child.childContextTypes = {text2: React.PropTypes.string};
1721 + Child.childContextTypes = {text2: PropTypes.string};
1722
1723 const Grandchild = (props, context) => {
1724 return (
@@ -1727,8 +1729,8 @@ describe('ReactDOMServerIntegration', () => {
1729 );
1730 };
1731 Grandchild.contextTypes = {
1730 - text1: React.PropTypes.string,
1731 - text2: React.PropTypes.string,
1732 + text1: PropTypes.string,
1733 + text2: PropTypes.string,
1734 };
1735
1736 const e = await render(<Parent />);
@@ -1750,12 +1752,12 @@ describe('ReactDOMServerIntegration', () => {
1752 return <Child />;
1753 }
1754 }
1753 - WillMountContext.childContextTypes = {text: React.PropTypes.string};
1755 + WillMountContext.childContextTypes = {text: PropTypes.string};
1756
1757 const Child = (props, context) => {
1758 return <div>{context.text}</div>;
1759 };
1758 - Child.contextTypes = {text: React.PropTypes.string};
1760 + Child.contextTypes = {text: PropTypes.string};
1761
1762 const e = await render(<WillMountContext />);
1763 expect(e.textContent).toBe('foo');
@@ -1788,7 +1790,7 @@ describe('ReactDOMServerIntegration', () => {
1790 return {value1: 'foo', value2: 'bar'};
1791 }
1792 }
1791 - Component.childContextTypes = {value1: React.PropTypes.string};
1793 + Component.childContextTypes = {value1: PropTypes.string};
1794 return render(<Component />);
1795 },
1796 );
src/renderers/dom/shared/__tests__/renderSubtreeIntoContainer-test.js
+17 -16
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React = require('react');
15 +var PropTypes = require('prop-types');
16 var ReactDOM = require('react-dom');
17 var ReactTestUtils = require('ReactTestUtils');
18 var renderSubtreeIntoContainer = require('renderSubtreeIntoContainer');
@@ -22,7 +23,7 @@ describe('renderSubtreeIntoContainer', () => {
23
24 class Component extends React.Component {
25 static contextTypes = {
25 - foo: React.PropTypes.string.isRequired,
26 + foo: PropTypes.string.isRequired,
27 };
28
29 render() {
@@ -32,7 +33,7 @@ describe('renderSubtreeIntoContainer', () => {
33
34 class Parent extends React.Component {
35 static childContextTypes = {
35 - foo: React.PropTypes.string.isRequired,
36 + foo: PropTypes.string.isRequired,
37 };
38
39 getChildContext() {
@@ -63,7 +64,7 @@ describe('renderSubtreeIntoContainer', () => {
64
65 class Component extends React.Component {
66 static contextTypes = {
66 - foo: React.PropTypes.string.isRequired,
67 + foo: PropTypes.string.isRequired,
68 };
69
70 render() {
@@ -76,7 +77,7 @@ describe('renderSubtreeIntoContainer', () => {
77 // eslint-disable-next-line no-unused-vars
78 class Parent extends React.Component {
79 static childContextTypes = {
79 - foo: React.PropTypes.string.isRequired,
80 + foo: PropTypes.string.isRequired,
81 };
82
83 getChildContext() {
@@ -104,8 +105,8 @@ describe('renderSubtreeIntoContainer', () => {
105
106 class Component extends React.Component {
107 static contextTypes = {
107 - foo: React.PropTypes.string.isRequired,
108 - getFoo: React.PropTypes.func.isRequired,
108 + foo: PropTypes.string.isRequired,
109 + getFoo: PropTypes.func.isRequired,
110 };
111
112 render() {
@@ -115,8 +116,8 @@ describe('renderSubtreeIntoContainer', () => {
116
117 class Parent extends React.Component {
118 static childContextTypes = {
118 - foo: React.PropTypes.string.isRequired,
119 - getFoo: React.PropTypes.func.isRequired,
119 + foo: PropTypes.string.isRequired,
120 + getFoo: PropTypes.func.isRequired,
121 };
122
123 state = {
@@ -156,8 +157,8 @@ describe('renderSubtreeIntoContainer', () => {
157
158 class Component extends React.Component {
159 static contextTypes = {
159 - foo: React.PropTypes.string.isRequired,
160 - getFoo: React.PropTypes.func.isRequired,
160 + foo: PropTypes.string.isRequired,
161 + getFoo: PropTypes.func.isRequired,
162 };
163
164 render() {
@@ -167,8 +168,8 @@ describe('renderSubtreeIntoContainer', () => {
168
169 class Parent extends React.Component {
170 static childContextTypes = {
170 - foo: React.PropTypes.string.isRequired,
171 - getFoo: React.PropTypes.func.isRequired,
171 + foo: PropTypes.string.isRequired,
172 + getFoo: PropTypes.func.isRequired,
173 };
174
175 getChildContext() {
@@ -229,7 +230,7 @@ describe('renderSubtreeIntoContainer', () => {
230 return {value: this.props.value};
231 }
232 static childContextTypes = {
232 - value: React.PropTypes.string.isRequired,
233 + value: PropTypes.string.isRequired,
234 };
235 }
236
@@ -244,7 +245,7 @@ describe('renderSubtreeIntoContainer', () => {
245
246 class Child extends React.Component {
247 static contextTypes = {
247 - value: React.PropTypes.string.isRequired,
248 + value: PropTypes.string.isRequired,
249 };
250 render() {
251 return <div>{this.context.value}</div>;
@@ -272,7 +273,7 @@ describe('renderSubtreeIntoContainer', () => {
273 renderSubtreeIntoContainer(this, <Middle />, portal1);
274 }
275 static childContextTypes = {
275 - value: React.PropTypes.string.isRequired,
276 + value: PropTypes.string.isRequired,
277 };
278 }
279
@@ -287,7 +288,7 @@ describe('renderSubtreeIntoContainer', () => {
288
289 class Child extends React.Component {
290 static contextTypes = {
290 - value: React.PropTypes.string.isRequired,
291 + value: PropTypes.string.isRequired,
292 };
293 render() {
294 return <div>{this.context.value}</div>;
src/renderers/dom/shared/utils/ReactControlledValuePropTypes.js
+2 -2
@@ -11,7 +11,7 @@
11
12 'use strict';
13
14 -var React = require('react');
14 +var PropTypes = require('prop-types');
15 var ReactPropTypesSecret = require('ReactPropTypesSecret');
16
17 var warning = require('fbjs/lib/warning');
@@ -57,7 +57,7 @@ var propTypes = {
57 'set either `onChange` or `readOnly`.',
58 );
59 },
60 - onChange: React.PropTypes.func,
60 + onChange: PropTypes.func,
61 };
62
63 var loggedTypeFailures = {};
src/renderers/native/__tests__/ReactNativeEvents-test.js
+3 -1
@@ -11,6 +11,7 @@
11
12 'use strict';
13
14 +var PropTypes;
15 var RCTEventEmitter;
16 var React;
17 var ReactNative;
@@ -21,6 +22,7 @@ var createReactNativeComponentClass;
22 beforeEach(() => {
23 jest.resetModules();
24
25 + PropTypes = require('prop-types');
26 RCTEventEmitter = require('RCTEventEmitter');
27 React = require('react');
28 ReactNative = require('ReactNative');
@@ -97,7 +99,7 @@ it('handles events on text nodes', () => {
99 });
100
101 class ContextHack extends React.Component {
100 - static childContextTypes = {isInAParentText: React.PropTypes.bool};
102 + static childContextTypes = {isInAParentText: PropTypes.bool};
103 getChildContext() {
104 return {isInAParentText: true};
105 }
src/renderers/shared/fiber/ReactFiberContext.js
+3 -5
@@ -15,7 +15,7 @@
15 import type {Fiber} from 'ReactFiber';
16 import type {StackCursor} from 'ReactFiberStack';
17
18 -var React = require('react');
18 +var checkPropTypes = require('checkPropTypes');
19 var emptyObject = require('fbjs/lib/emptyObject');
20 var getComponentName = require('getComponentName');
21 var invariant = require('fbjs/lib/invariant');
@@ -105,8 +105,7 @@ exports.getMaskedContext = function(
105 if (__DEV__) {
106 const name = getComponentName(workInProgress) || 'Unknown';
107 ReactDebugCurrentFrame.current = workInProgress;
108 - // $FlowFixMe - We know this export exists now, need to wait for Flow update
109 - React.checkPropTypes(
108 + checkPropTypes(
109 contextTypes,
110 context,
111 'context',
@@ -219,8 +218,7 @@ function processChildContext(
218 // TODO: remove this hack when we delete unstable_renderSubtree in Fiber.
219 const workInProgress = isReconciling ? fiber : null;
220 ReactDebugCurrentFrame.current = workInProgress;
222 - // $FlowFixMe - We know this export exists now, need to wait for Flow update
223 - React.checkPropTypes(
221 + checkPropTypes(
222 childContextTypes,
223 childContext,
224 'child context',
src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
+18 -16
@@ -14,12 +14,14 @@
14 var React;
15 var ReactNoop;
16 var ReactFeatureFlags;
17 +var PropTypes;
18
19 describe('ReactIncremental', () => {
20 beforeEach(() => {
21 jest.resetModules();
22 React = require('react');
23 ReactNoop = require('ReactNoop');
24 + PropTypes = require('prop-types');
25
26 ReactFeatureFlags = require('ReactFeatureFlags');
27 ReactFeatureFlags.disableNewFiberFeatures = false;
@@ -1592,7 +1594,7 @@ describe('ReactIncremental', () => {
1594
1595 class Intl extends React.Component {
1596 static childContextTypes = {
1595 - locale: React.PropTypes.string,
1597 + locale: PropTypes.string,
1598 };
1599 getChildContext() {
1600 return {
@@ -1607,7 +1609,7 @@ describe('ReactIncremental', () => {
1609
1610 class Router extends React.Component {
1611 static childContextTypes = {
1610 - route: React.PropTypes.string,
1612 + route: PropTypes.string,
1613 };
1614 getChildContext() {
1615 return {
@@ -1622,7 +1624,7 @@ describe('ReactIncremental', () => {
1624
1625 class ShowLocale extends React.Component {
1626 static contextTypes = {
1625 - locale: React.PropTypes.string,
1627 + locale: PropTypes.string,
1628 };
1629 render() {
1630 ops.push('ShowLocale ' + JSON.stringify(this.context));
@@ -1632,7 +1634,7 @@ describe('ReactIncremental', () => {
1634
1635 class ShowRoute extends React.Component {
1636 static contextTypes = {
1635 - route: React.PropTypes.string,
1637 + route: PropTypes.string,
1638 };
1639 render() {
1640 ops.push('ShowRoute ' + JSON.stringify(this.context));
@@ -1645,8 +1647,8 @@ describe('ReactIncremental', () => {
1647 return `${context.route} in ${context.locale}`;
1648 }
1649 ShowBoth.contextTypes = {
1648 - locale: React.PropTypes.string,
1649 - route: React.PropTypes.string,
1650 + locale: PropTypes.string,
1651 + route: PropTypes.string,
1652 };
1653
1654 class ShowNeither extends React.Component {
@@ -1745,10 +1747,10 @@ describe('ReactIncremental', () => {
1747 var ops = [];
1748 class Recurse extends React.Component {
1749 static contextTypes = {
1748 - n: React.PropTypes.number,
1750 + n: PropTypes.number,
1751 };
1752 static childContextTypes = {
1751 - n: React.PropTypes.number,
1753 + n: PropTypes.number,
1754 };
1755 getChildContext() {
1756 return {n: (this.context.n || 3) - 1};
@@ -1777,7 +1779,7 @@ describe('ReactIncremental', () => {
1779
1780 class Intl extends React.Component {
1781 static childContextTypes = {
1780 - locale: React.PropTypes.string,
1782 + locale: PropTypes.string,
1783 };
1784 getChildContext() {
1785 return {
@@ -1792,7 +1794,7 @@ describe('ReactIncremental', () => {
1794
1795 class ShowLocale extends React.Component {
1796 static contextTypes = {
1795 - locale: React.PropTypes.string,
1797 + locale: PropTypes.string,
1798 };
1799 render() {
1800 ops.push('ShowLocale ' + JSON.stringify(this.context));
@@ -1835,7 +1837,7 @@ describe('ReactIncremental', () => {
1837
1838 class Intl extends React.Component {
1839 static childContextTypes = {
1838 - locale: React.PropTypes.string,
1840 + locale: PropTypes.string,
1841 };
1842 getChildContext() {
1843 const childContext = {
@@ -1852,7 +1854,7 @@ describe('ReactIncremental', () => {
1854
1855 class ShowLocaleClass extends React.Component {
1856 static contextTypes = {
1855 - locale: React.PropTypes.string,
1857 + locale: PropTypes.string,
1858 };
1859 render() {
1860 ops.push('ShowLocaleClass:read ' + JSON.stringify(this.context));
@@ -1865,7 +1867,7 @@ describe('ReactIncremental', () => {
1867 return context.locale;
1868 }
1869 ShowLocaleFn.contextTypes = {
1868 - locale: React.PropTypes.string,
1870 + locale: PropTypes.string,
1871 };
1872
1873 class Stateful extends React.Component {
@@ -1925,7 +1927,7 @@ describe('ReactIncremental', () => {
1927
1928 class Intl extends React.Component {
1929 static childContextTypes = {
1928 - locale: React.PropTypes.string,
1930 + locale: PropTypes.string,
1931 };
1932 getChildContext() {
1933 const childContext = {
@@ -1942,7 +1944,7 @@ describe('ReactIncremental', () => {
1944
1945 class ShowLocaleClass extends React.Component {
1946 static contextTypes = {
1945 - locale: React.PropTypes.string,
1947 + locale: PropTypes.string,
1948 };
1949 render() {
1950 ops.push('ShowLocaleClass:read ' + JSON.stringify(this.context));
@@ -1955,7 +1957,7 @@ describe('ReactIncremental', () => {
1957 return context.locale;
1958 }
1959 ShowLocaleFn.contextTypes = {
1958 - locale: React.PropTypes.string,
1960 + locale: PropTypes.string,
1961 };
1962
1963 function IndirectionFn(props, context) {
src/renderers/shared/fiber/__tests__/ReactIncrementalErrorHandling-test.js
+5 -3
@@ -11,6 +11,7 @@
11
12 'use strict';
13
14 +var PropTypes;
15 var React;
16 var ReactNoop;
17 var ReactFeatureFlags;
@@ -18,6 +19,7 @@ var ReactFeatureFlags;
19 describe('ReactIncrementalErrorHandling', () => {
20 beforeEach(() => {
21 jest.resetModules();
22 + PropTypes = require('prop-types');
23 React = require('react');
24 ReactNoop = require('ReactNoop');
25 ReactFeatureFlags = require('ReactFeatureFlags');
@@ -679,8 +681,8 @@ describe('ReactIncrementalErrorHandling', () => {
681
682 it('unwinds the context stack correctly on error', () => {
683 class Provider extends React.Component {
682 - static childContextTypes = {message: React.PropTypes.string};
683 - static contextTypes = {message: React.PropTypes.string};
684 + static childContextTypes = {message: PropTypes.string};
685 + static contextTypes = {message: PropTypes.string};
686 getChildContext() {
687 return {
688 message: (this.context.message || '') + this.props.message,
@@ -696,7 +698,7 @@ describe('ReactIncrementalErrorHandling', () => {
698 }
699
700 Connector.contextTypes = {
699 - message: React.PropTypes.string,
701 + message: PropTypes.string,
702 };
703
704 function BadRender() {
src/renderers/shared/fiber/__tests__/ReactIncrementalPerf-test.js
+3 -1
@@ -17,6 +17,7 @@ describe('ReactDebugFiberPerf', () => {
17 let ReactFeatureFlags;
18 let ReactNoop;
19 let ReactPortal;
20 + let PropTypes;
21
22 let root;
23 let activeMeasure;
@@ -119,6 +120,7 @@ describe('ReactDebugFiberPerf', () => {
120 ReactNoop = require('ReactNoop');
121 ReactPortal = require('ReactPortal');
122 ReactFeatureFlags.disableNewFiberFeatures = false;
123 + PropTypes = require('prop-types');
124 });
125
126 afterEach(() => {
@@ -245,7 +247,7 @@ describe('ReactDebugFiberPerf', () => {
247 it('captures all lifecycles', () => {
248 class AllLifecycles extends React.Component {
249 static childContextTypes = {
248 - foo: React.PropTypes.any,
250 + foo: PropTypes.any,
251 };
252 shouldComponentUpdate() {
253 return true;
src/renderers/shared/stack/reconciler/ReactCompositeComponent.js
+2 -1
@@ -27,6 +27,7 @@ if (__DEV__) {
27 var warningAboutMissingGetChildContext = {};
28 }
29
30 +var checkPropTypes = require('checkPropTypes');
31 var emptyObject = require('fbjs/lib/emptyObject');
32 var invariant = require('fbjs/lib/invariant');
33 var shallowEqual = require('fbjs/lib/shallowEqual');
@@ -729,7 +730,7 @@ var ReactCompositeComponent = {
730 _checkContextTypes: function(typeSpecs, values, location: string) {
731 if (__DEV__) {
732 ReactDebugCurrentFrame.current = this._debugID;
732 - React.checkPropTypes(
733 + checkPropTypes(
734 typeSpecs,
735 values,
736 location,
src/test/__tests__/ReactTestUtils-test.js
+5 -3
@@ -11,6 +11,7 @@
11
12 'use strict';
13
14 +var PropTypes;
15 var React;
16 var ReactDOM;
17 var ReactDOMServer;
@@ -18,6 +19,7 @@ var ReactTestUtils;
19
20 describe('ReactTestUtils', () => {
21 beforeEach(() => {
22 + PropTypes = require('prop-types');
23 React = require('react');
24 ReactDOM = require('react-dom');
25 ReactDOMServer = require('react-dom/server');
@@ -195,7 +197,7 @@ describe('ReactTestUtils', () => {
197 it('can shallowly render components with contextTypes', () => {
198 class SimpleComponent extends React.Component {
199 static contextTypes = {
198 - name: React.PropTypes.string,
200 + name: PropTypes.string,
201 };
202
203 render() {
@@ -258,7 +260,7 @@ describe('ReactTestUtils', () => {
260 it('can pass context when shallowly rendering', () => {
261 class SimpleComponent extends React.Component {
262 static contextTypes = {
261 - name: React.PropTypes.string,
263 + name: PropTypes.string,
264 };
265
266 render() {
@@ -278,7 +280,7 @@ describe('ReactTestUtils', () => {
280
281 class SimpleComponent extends React.Component {
282 static contextTypes = {
281 - name: React.PropTypes.string.isRequired,
283 + name: PropTypes.string.isRequired,
284 };
285
286 render() {
yarn.lock
+10 -3
@@ -1438,11 +1438,12 @@ create-hmac@^1.1.0, create-hmac@^1.1.2:
1438 create-hash "^1.1.0"
1439 inherits "^2.0.1"
1440
1441 -create-react-class@^15.5.0:
1442 - version "15.5.0"
1443 - resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.5.0.tgz#7508ffcad56a0804fb244d6ff70b07648abfe5fb"
1441 +create-react-class@^15.5.2:
1442 + version "15.5.2"
1443 + resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.5.2.tgz#6a8758348df660b88326a0e764d569f274aad681"
1444 dependencies:
1445 fbjs "^0.8.9"
1446 + object-assign "^4.1.1"
1447
1448 cross-spawn-async@^2.2.2:
1449 version "2.2.5"
@@ -3929,6 +3930,12 @@ promise@^7.1.1:
3930 dependencies:
3931 asap "~2.0.3"
3932
3933 +prop-types@^15.5.6:
3934 + version "15.5.6"
3935 + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.6.tgz#797a915b1714b645ebb7c5d6cc690346205bd2aa"
3936 + dependencies:
3937 + fbjs "^0.8.9"
3938 +
3939 prr@~0.0.0:
3940 version "0.0.0"
3941 resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a"