Skip to content

Commit 7b85bc9

Browse files
committed
[wip] remove prop types
1 parent 4b2a111 commit 7b85bc9

19 files changed

+14
-838
lines changed

packages/react-art/npm/Circle.js

Lines changed: 0 additions & 5 deletions
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

Lines changed: 0 additions & 11 deletions
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

Lines changed: 0 additions & 8 deletions
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

Lines changed: 0 additions & 39 deletions
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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,9 @@ describe('ReactFunctionComponent', () => {
391391
return <div>{props.test}</div>;
392392
}
393393
Child.defaultProps = {test: 2};
394-
Child.propTypes = {test: PropTypes.string};
395394

396395
expect(() => ReactTestUtils.renderIntoDocument(<Child />)).toErrorDev([
397396
'Warning: Child: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.',
398-
'Warning: Failed prop type: Invalid prop `test` of type `number` ' +
399-
'supplied to `Child`, expected `string`.\n' +
400-
' in Child (at **)',
401397
]);
402398
});
403399

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -401,22 +401,6 @@ function updateForwardRef(
401401
// hasn't yet mounted. This happens after the first render suspends.
402402
// We'll need to figure out if this is fine or can cause issues.
403403

404-
if (__DEV__) {
405-
if (workInProgress.type !== workInProgress.elementType) {
406-
// Lazy component props can't be validated in createElement
407-
// because they're only guaranteed to be resolved here.
408-
const innerPropTypes = Component.propTypes;
409-
if (innerPropTypes) {
410-
checkPropTypes(
411-
innerPropTypes,
412-
nextProps, // Resolved props
413-
'prop',
414-
getComponentNameFromType(Component),
415-
);
416-
}
417-
}
418-
}
419-
420404
const render = Component.render;
421405
const ref = workInProgress.ref;
422406

@@ -506,17 +490,6 @@ function updateMemoComponent(
506490
);
507491
}
508492
if (__DEV__) {
509-
const innerPropTypes = type.propTypes;
510-
if (innerPropTypes) {
511-
// Inner memo component props aren't currently validated in createElement.
512-
// We could move it there, but we'd still need this for lazy code path.
513-
checkPropTypes(
514-
innerPropTypes,
515-
nextProps, // Resolved props
516-
'prop',
517-
getComponentNameFromType(type),
518-
);
519-
}
520493
if (Component.defaultProps !== undefined) {
521494
const componentName = getComponentNameFromType(type) || 'Unknown';
522495
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
@@ -543,20 +516,6 @@ function updateMemoComponent(
543516
workInProgress.child = child;
544517
return child;
545518
}
546-
if (__DEV__) {
547-
const type = Component.type;
548-
const innerPropTypes = type.propTypes;
549-
if (innerPropTypes) {
550-
// Inner memo component props aren't currently validated in createElement.
551-
// We could move it there, but we'd still need this for lazy code path.
552-
checkPropTypes(
553-
innerPropTypes,
554-
nextProps, // Resolved props
555-
'prop',
556-
getComponentNameFromType(type),
557-
);
558-
}
559-
}
560519
const currentChild = ((current.child: any): Fiber); // This is always exactly one child
561520
const hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(
562521
current,
@@ -592,37 +551,6 @@ function updateSimpleMemoComponent(
592551
// TODO: current can be non-null here even if the component
593552
// hasn't yet mounted. This happens when the inner render suspends.
594553
// We'll need to figure out if this is fine or can cause issues.
595-
596-
if (__DEV__) {
597-
if (workInProgress.type !== workInProgress.elementType) {
598-
// Lazy component props can't be validated in createElement
599-
// because they're only guaranteed to be resolved here.
600-
let outerMemoType = workInProgress.elementType;
601-
if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
602-
// We warn when you define propTypes on lazy()
603-
// so let's just skip over it to find memo() outer wrapper.
604-
// Inner props for memo are validated later.
605-
const lazyComponent: LazyComponentType<any, any> = outerMemoType;
606-
const payload = lazyComponent._payload;
607-
const init = lazyComponent._init;
608-
try {
609-
outerMemoType = init(payload);
610-
} catch (x) {
611-
outerMemoType = null;
612-
}
613-
// Inner propTypes will be validated in the function component path.
614-
const outerPropTypes = outerMemoType && (outerMemoType: any).propTypes;
615-
if (outerPropTypes) {
616-
checkPropTypes(
617-
outerPropTypes,
618-
nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
619-
'prop',
620-
getComponentNameFromType(outerMemoType),
621-
);
622-
}
623-
}
624-
}
625-
}
626554
if (current !== null) {
627555
const prevProps = current.memoizedProps;
628556
if (
@@ -1099,22 +1027,6 @@ function updateFunctionComponent(
10991027
nextProps: any,
11001028
renderLanes: Lanes,
11011029
) {
1102-
if (__DEV__) {
1103-
if (workInProgress.type !== workInProgress.elementType) {
1104-
// Lazy component props can't be validated in createElement
1105-
// because they're only guaranteed to be resolved here.
1106-
const innerPropTypes = Component.propTypes;
1107-
if (innerPropTypes) {
1108-
checkPropTypes(
1109-
innerPropTypes,
1110-
nextProps, // Resolved props
1111-
'prop',
1112-
getComponentNameFromType(Component),
1113-
);
1114-
}
1115-
}
1116-
}
1117-
11181030
let context;
11191031
if (!disableLegacyContext) {
11201032
const unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
@@ -1253,20 +1165,6 @@ function updateClassComponent(
12531165
break;
12541166
}
12551167
}
1256-
1257-
if (workInProgress.type !== workInProgress.elementType) {
1258-
// Lazy component props can't be validated in createElement
1259-
// because they're only guaranteed to be resolved here.
1260-
const innerPropTypes = Component.propTypes;
1261-
if (innerPropTypes) {
1262-
checkPropTypes(
1263-
innerPropTypes,
1264-
nextProps, // Resolved props
1265-
'prop',
1266-
getComponentNameFromType(Component),
1267-
);
1268-
}
1269-
}
12701168
}
12711169

12721170
// Push context providers early to prevent context stack mismatches.
@@ -1815,19 +1713,6 @@ function mountLazyComponent(
18151713
return child;
18161714
}
18171715
case MemoComponent: {
1818-
if (__DEV__) {
1819-
if (workInProgress.type !== workInProgress.elementType) {
1820-
const outerPropTypes = Component.propTypes;
1821-
if (outerPropTypes) {
1822-
checkPropTypes(
1823-
outerPropTypes,
1824-
resolvedProps, // Resolved for outer only
1825-
'prop',
1826-
getComponentNameFromType(Component),
1827-
);
1828-
}
1829-
}
1830-
}
18311716
child = updateMemoComponent(
18321717
null,
18331718
workInProgress,
@@ -4237,19 +4122,6 @@ function beginWork(
42374122
const unresolvedProps = workInProgress.pendingProps;
42384123
// Resolve outer props first, then resolve inner props.
42394124
let resolvedProps = resolveDefaultProps(type, unresolvedProps);
4240-
if (__DEV__) {
4241-
if (workInProgress.type !== workInProgress.elementType) {
4242-
const outerPropTypes = type.propTypes;
4243-
if (outerPropTypes) {
4244-
checkPropTypes(
4245-
outerPropTypes,
4246-
resolvedProps, // Resolved for outer only
4247-
'prop',
4248-
getComponentNameFromType(type),
4249-
);
4250-
}
4251-
}
4252-
}
42534125
resolvedProps = resolveDefaultProps(type.type, resolvedProps);
42544126
return updateMemoComponent(
42554127
current,

packages/react-reconciler/src/ReactFiberClassComponent.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,6 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
395395
name,
396396
);
397397
}
398-
if (instance.propTypes) {
399-
console.error(
400-
'propTypes was defined as an instance property on %s. Use a static ' +
401-
'property to define propTypes instead.',
402-
name,
403-
);
404-
}
405398
if (instance.contextType) {
406399
console.error(
407400
'contextType was defined as an instance property on %s. Use a static ' +

0 commit comments

Comments
 (0)