Skip to content

Commit d7d3ca0

Browse files
committed
Remove JSX propTypes checks
1 parent a515d75 commit d7d3ca0

10 files changed

+56
-632
lines changed

packages/react-art/npm/Circle.js

-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
'use strict';
1919

2020
var assign = Object.assign;
21-
var PropTypes = require('prop-types');
2221
var React = require('react');
2322
var ReactART = require('react-art');
2423

@@ -34,10 +33,6 @@ var Shape = ReactART.Shape;
3433
var Circle = createReactClass({
3534
displayName: 'Circle',
3635

37-
propTypes: {
38-
radius: PropTypes.number.isRequired,
39-
},
40-
4136
render: function render() {
4237
var radius = this.props.radius;
4338

packages/react-art/npm/Rectangle.js

-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
'use strict';
2626

2727
var assign = Object.assign;
28-
var PropTypes = require('prop-types');
2928
var React = require('react');
3029
var ReactART = require('react-art');
3130

@@ -41,16 +40,6 @@ var Path = ReactART.Path;
4140
var Rectangle = createReactClass({
4241
displayName: 'Rectangle',
4342

44-
propTypes: {
45-
width: PropTypes.number.isRequired,
46-
height: PropTypes.number.isRequired,
47-
radius: PropTypes.number,
48-
radiusTopLeft: PropTypes.number,
49-
radiusTopRight: PropTypes.number,
50-
radiusBottomRight: PropTypes.number,
51-
radiusBottomLeft: PropTypes.number,
52-
},
53-
5443
render: function render() {
5544
var width = this.props.width;
5645
var height = this.props.height;

packages/react-art/npm/Wedge.js

-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
'use strict';
2222

2323
var assign = Object.assign;
24-
var PropTypes = require('prop-types');
2524
var React = require('react');
2625
var ReactART = require('react-art');
2726

@@ -37,13 +36,6 @@ var Path = ReactART.Path;
3736
var Wedge = createReactClass({
3837
displayName: 'Wedge',
3938

40-
propTypes: {
41-
outerRadius: PropTypes.number.isRequired,
42-
startAngle: PropTypes.number.isRequired,
43-
endAngle: PropTypes.number.isRequired,
44-
innerRadius: PropTypes.number,
45-
},
46-
4739
circleRadians: Math.PI * 2,
4840

4941
radiansPerDegree: Math.PI / 180,

packages/react-art/src/__tests__/ReactART-test.js

-39
Original file line numberDiff line numberDiff line change
@@ -456,18 +456,6 @@ describe('ReactARTComponents', () => {
456456
expect(circle.toJSON()).toMatchSnapshot();
457457
});
458458

459-
it('should warn if radius is missing on a Circle component', () => {
460-
expect(() =>
461-
ReactTestRenderer.create(
462-
<Circle stroke="green" strokeWidth={3} fill="blue" />,
463-
),
464-
).toErrorDev(
465-
'Warning: Failed prop type: The prop `radius` is marked as required in `Circle`, ' +
466-
'but its value is `undefined`.' +
467-
'\n in Circle (at **)',
468-
);
469-
});
470-
471459
it('should generate a <Shape> with props for drawing the Rectangle', () => {
472460
const rectangle = ReactTestRenderer.create(
473461
<Rectangle width={50} height={50} stroke="green" fill="blue" />,
@@ -529,19 +517,6 @@ describe('ReactARTComponents', () => {
529517
expect(rectangle.toJSON()).toMatchSnapshot();
530518
});
531519

532-
it('should warn if width/height is missing on a Rectangle component', () => {
533-
expect(() =>
534-
ReactTestRenderer.create(<Rectangle stroke="green" fill="blue" />),
535-
).toErrorDev([
536-
'Warning: Failed prop type: The prop `width` is marked as required in `Rectangle`, ' +
537-
'but its value is `undefined`.' +
538-
'\n in Rectangle (at **)',
539-
'Warning: Failed prop type: The prop `height` is marked as required in `Rectangle`, ' +
540-
'but its value is `undefined`.' +
541-
'\n in Rectangle (at **)',
542-
]);
543-
});
544-
545520
it('should generate a <Shape> with props for drawing the Wedge', () => {
546521
const wedge = ReactTestRenderer.create(
547522
<Wedge outerRadius={50} startAngle={0} endAngle={360} fill="blue" />,
@@ -555,18 +530,4 @@ describe('ReactARTComponents', () => {
555530
);
556531
expect(wedge.toJSON()).toBeNull();
557532
});
558-
559-
it('should warn if outerRadius/startAngle/endAngle is missing on a Wedge component', () => {
560-
expect(() => ReactTestRenderer.create(<Wedge fill="blue" />)).toErrorDev([
561-
'Warning: Failed prop type: The prop `outerRadius` is marked as required in `Wedge`, ' +
562-
'but its value is `undefined`.' +
563-
'\n in Wedge (at **)',
564-
'Warning: Failed prop type: The prop `startAngle` is marked as required in `Wedge`, ' +
565-
'but its value is `undefined`.' +
566-
'\n in Wedge (at **)',
567-
'Warning: Failed prop type: The prop `endAngle` is marked as required in `Wedge`, ' +
568-
'but its value is `undefined`.' +
569-
'\n in Wedge (at **)',
570-
]);
571-
});
572533
});

packages/react-dom/src/__tests__/ReactFunctionComponent-test.js

+45-51
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('ReactFunctionComponent', () => {
9494
};
9595

9696
getChildContext() {
97-
return {test: this.props.test};
97+
return { test: this.props.test };
9898
}
9999

100100
render() {
@@ -122,7 +122,7 @@ describe('ReactFunctionComponent', () => {
122122
function FunctionComponentWithChildContext() {
123123
return null;
124124
}
125-
FunctionComponentWithChildContext.getDerivedStateFromProps = function () {};
125+
FunctionComponentWithChildContext.getDerivedStateFromProps = function() { };
126126

127127
const container = document.createElement('div');
128128

@@ -133,7 +133,7 @@ describe('ReactFunctionComponent', () => {
133133
});
134134
}).toErrorDev(
135135
'FunctionComponentWithChildContext: Function ' +
136-
'components do not support getDerivedStateFromProps.',
136+
'components do not support getDerivedStateFromProps.',
137137
);
138138
});
139139

@@ -155,12 +155,12 @@ describe('ReactFunctionComponent', () => {
155155
});
156156
}).toErrorDev(
157157
'FunctionComponentWithChildContext(...): childContextTypes cannot ' +
158-
'be defined on a function component.',
158+
'be defined on a function component.',
159159
);
160160
});
161161

162162
it('should not throw when stateless component returns undefined', async () => {
163-
function NotAComponent() {}
163+
function NotAComponent() { }
164164
const container = document.createElement('div');
165165
const root = ReactDOMClient.createRoot(container);
166166
await expect(
@@ -189,13 +189,13 @@ describe('ReactFunctionComponent', () => {
189189
__DEV__
190190
? 'Function components cannot have string refs. We recommend using useRef() instead.'
191191
: // It happens because we don't save _owner in production for
192-
// function components.
193-
'Element ref was specified as a string (me) but no owner was set. This could happen for one of' +
194-
' the following reasons:\n' +
195-
'1. You may be adding a ref to a function component\n' +
196-
"2. You may be adding a ref to a component that was not created inside a component's render method\n" +
197-
'3. You have multiple copies of React loaded\n' +
198-
'See https://reactjs.org/link/refs-must-have-owner for more information.',
192+
// function components.
193+
'Element ref was specified as a string (me) but no owner was set. This could happen for one of' +
194+
' the following reasons:\n' +
195+
'1. You may be adding a ref to a function component\n' +
196+
"2. You may be adding a ref to a component that was not created inside a component's render method\n" +
197+
'3. You have multiple copies of React loaded\n' +
198+
'See https://reactjs.org/link/refs-must-have-owner for more information.',
199199
);
200200
});
201201

@@ -222,14 +222,14 @@ describe('ReactFunctionComponent', () => {
222222
});
223223
}).toErrorDev(
224224
'Warning: Function components cannot be given refs. ' +
225-
'Attempts to access this ref will fail. ' +
226-
'Did you mean to use React.forwardRef()?\n\n' +
227-
'Check the render method ' +
228-
'of `ParentUsingStringRef`.\n' +
229-
' in FunctionComponent (at **)\n' +
230-
' in div (at **)\n' +
231-
' in Indirection (at **)\n' +
232-
' in ParentUsingStringRef (at **)',
225+
'Attempts to access this ref will fail. ' +
226+
'Did you mean to use React.forwardRef()?\n\n' +
227+
'Check the render method ' +
228+
'of `ParentUsingStringRef`.\n' +
229+
' in FunctionComponent (at **)\n' +
230+
' in div (at **)\n' +
231+
' in Indirection (at **)\n' +
232+
' in ParentUsingStringRef (at **)',
233233
);
234234

235235
// No additional warnings should be logged
@@ -264,14 +264,14 @@ describe('ReactFunctionComponent', () => {
264264
});
265265
}).toErrorDev(
266266
'Warning: Function components cannot be given refs. ' +
267-
'Attempts to access this ref will fail. ' +
268-
'Did you mean to use React.forwardRef()?\n\n' +
269-
'Check the render method ' +
270-
'of `ParentUsingFunctionRef`.\n' +
271-
' in FunctionComponent (at **)\n' +
272-
' in div (at **)\n' +
273-
' in Indirection (at **)\n' +
274-
' in ParentUsingFunctionRef (at **)',
267+
'Attempts to access this ref will fail. ' +
268+
'Did you mean to use React.forwardRef()?\n\n' +
269+
'Check the render method ' +
270+
'of `ParentUsingFunctionRef`.\n' +
271+
' in FunctionComponent (at **)\n' +
272+
' in div (at **)\n' +
273+
' in Indirection (at **)\n' +
274+
' in ParentUsingFunctionRef (at **)',
275275
);
276276
expect(ref).not.toHaveBeenCalled();
277277

@@ -287,7 +287,7 @@ describe('ReactFunctionComponent', () => {
287287
// When owner uses JSX, we can use exact line location to dedupe warnings
288288
class AnonymousParentUsingJSX extends React.Component {
289289
render() {
290-
return <FunctionComponent name="A" ref={() => {}} />;
290+
return <FunctionComponent name="A" ref={() => { }} />;
291291
}
292292
}
293293

@@ -317,7 +317,7 @@ describe('ReactFunctionComponent', () => {
317317
render() {
318318
return React.createElement(FunctionComponent, {
319319
name: 'A',
320-
ref: () => {},
320+
ref: () => { },
321321
});
322322
}
323323
}
@@ -346,7 +346,7 @@ describe('ReactFunctionComponent', () => {
346346
render() {
347347
return React.createElement(FunctionComponent, {
348348
name: 'A',
349-
ref: () => {},
349+
ref: () => { },
350350
});
351351
}
352352
}
@@ -391,7 +391,7 @@ describe('ReactFunctionComponent', () => {
391391
};
392392
}
393393
render() {
394-
return <Child ref={function () {}} />;
394+
return <Child ref={function() { }} />;
395395
}
396396
}
397397

@@ -403,12 +403,12 @@ describe('ReactFunctionComponent', () => {
403403
});
404404
}).toErrorDev(
405405
'Warning: Function components cannot be given refs. ' +
406-
'Attempts to access this ref will fail. ' +
407-
'Did you mean to use React.forwardRef()?\n\n' +
408-
'Check the render method ' +
409-
'of `Parent`.\n' +
410-
' in Child (at **)\n' +
411-
' in Parent (at **)',
406+
'Attempts to access this ref will fail. ' +
407+
'Did you mean to use React.forwardRef()?\n\n' +
408+
'Check the render method ' +
409+
'of `Parent`.\n' +
410+
' in Child (at **)\n' +
411+
' in Parent (at **)',
412412
);
413413
});
414414

@@ -425,18 +425,15 @@ describe('ReactFunctionComponent', () => {
425425
});
426426
}).toErrorDev(
427427
'Each child in a list should have a unique "key" prop.\n\n' +
428-
'Check the render method of `Child`.',
428+
'Check the render method of `Child`.',
429429
);
430430
});
431431

432-
// TODO: change this test after we deprecate default props support
433-
// for function components
434-
it('should support default props and prop types', async () => {
432+
it('should support default props', () => {
435433
function Child(props) {
436434
return <div>{props.test}</div>;
437435
}
438-
Child.defaultProps = {test: 2};
439-
Child.propTypes = {test: PropTypes.string};
436+
Child.defaultProps = { test: 2 };
440437

441438
await expect(async () => {
442439
const container = document.createElement('div');
@@ -447,9 +444,6 @@ describe('ReactFunctionComponent', () => {
447444
});
448445
}).toErrorDev([
449446
'Warning: Child: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.',
450-
'Warning: Failed prop type: Invalid prop `test` of type `number` ' +
451-
'supplied to `Child`, expected `string`.\n' +
452-
' in Child (at **)',
453447
]);
454448
});
455449

@@ -461,7 +455,7 @@ describe('ReactFunctionComponent', () => {
461455
};
462456

463457
getChildContext() {
464-
return {lang: 'en'};
458+
return { lang: 'en' };
465459
}
466460

467461
render() {
@@ -472,7 +466,7 @@ describe('ReactFunctionComponent', () => {
472466
function Child(props, context) {
473467
return <div>{context.lang}</div>;
474468
}
475-
Child.contextTypes = {lang: PropTypes.string};
469+
Child.contextTypes = { lang: PropTypes.string };
476470

477471
const el = document.createElement('div');
478472

@@ -484,7 +478,7 @@ describe('ReactFunctionComponent', () => {
484478
});
485479

486480
it('should work with arrow functions', async () => {
487-
let Child = function () {
481+
let Child = function() {
488482
return <div />;
489483
};
490484
// Will create a new bound function without a prototype, much like a native
@@ -501,7 +495,7 @@ describe('ReactFunctionComponent', () => {
501495
});
502496

503497
it('should allow simple functions to return null', async () => {
504-
const Child = function () {
498+
const Child = function() {
505499
return null;
506500
};
507501
await expect(async () => {

0 commit comments

Comments
 (0)