Skip to content

Commit d72700f

Browse files
authored
Remove runtime dependency on prop-types (#18127)
* Remove runtime dep on prop-types * Fix test
1 parent 549e418 commit d72700f

File tree

16 files changed

+94
-74
lines changed

16 files changed

+94
-74
lines changed

packages/react-art/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"create-react-class": "^15.6.2",
2727
"loose-envify": "^1.1.0",
2828
"object-assign": "^4.1.1",
29-
"prop-types": "^15.6.2",
3029
"scheduler": "^0.19.0"
3130
},
3231
"peerDependencies": {

packages/react-dom/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"dependencies": {
2020
"loose-envify": "^1.1.0",
2121
"object-assign": "^4.1.1",
22-
"prop-types": "^15.6.2",
2322
"scheduler": "^0.19.0"
2423
},
2524
"peerDependencies": {

packages/react-dom/src/server/ReactPartialRendererContext.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ import type {ReactContext} from 'shared/ReactTypes';
1212

1313
import {disableLegacyContext} from 'shared/ReactFeatureFlags';
1414
import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
15-
import ReactSharedInternals from 'shared/ReactSharedInternals';
1615
import getComponentName from 'shared/getComponentName';
17-
import checkPropTypes from 'prop-types/checkPropTypes';
16+
import checkPropTypes from 'shared/checkPropTypes';
1817

19-
let ReactDebugCurrentFrame;
2018
let didWarnAboutInvalidateContextType;
2119
if (__DEV__) {
22-
ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
2320
didWarnAboutInvalidateContextType = new Set();
2421
}
2522

@@ -42,13 +39,7 @@ function maskContext(type, context) {
4239

4340
function checkContextTypes(typeSpecs, values, location: string) {
4441
if (__DEV__) {
45-
checkPropTypes(
46-
typeSpecs,
47-
values,
48-
location,
49-
'Component',
50-
ReactDebugCurrentFrame.getCurrentStack,
51-
);
42+
checkPropTypes(typeSpecs, values, location, 'Component');
5243
}
5344
}
5445

packages/react-dom/src/shared/ReactControlledValuePropTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import checkPropTypes from 'prop-types/checkPropTypes';
8+
import checkPropTypes from 'shared/checkPropTypes';
99
import ReactSharedInternals from 'shared/ReactSharedInternals';
1010
import {enableDeprecatedFlareAPI} from 'shared/ReactFeatureFlags';
1111

packages/react-flight/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
},
3030
"dependencies": {
3131
"loose-envify": "^1.1.0",
32-
"object-assign": "^4.1.1",
33-
"prop-types": "^15.6.2"
32+
"object-assign": "^4.1.1"
3433
},
3534
"browserify": {
3635
"transform": [

packages/react-native-renderer/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
},
1010
"dependencies": {
1111
"object-assign": "^4.1.1",
12-
"prop-types": "^15.6.2",
1312
"scheduler": "^0.11.0"
1413
},
1514
"peerDependencies": {

packages/react-noop-renderer/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"license": "MIT",
1313
"dependencies": {
1414
"object-assign": "^4.1.1",
15-
"prop-types": "^15.6.2",
1615
"regenerator-runtime": "^0.11.0",
1716
"react-reconciler": "*",
1817
"react-flight": "*",

packages/react-reconciler/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"dependencies": {
3333
"loose-envify": "^1.1.0",
3434
"object-assign": "^4.1.1",
35-
"prop-types": "^15.6.2",
3635
"scheduler": "^0.19.0"
3736
},
3837
"browserify": {

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818
} from './ReactFiberSuspenseComponent';
1919
import type {SuspenseContext} from './ReactFiberSuspenseContext';
2020

21-
import checkPropTypes from 'prop-types/checkPropTypes';
21+
import checkPropTypes from 'shared/checkPropTypes';
2222

2323
import {
2424
IndeterminateComponent,
@@ -75,7 +75,6 @@ import {refineResolvedLazyComponent} from 'shared/ReactLazyComponent';
7575
import {REACT_LAZY_TYPE, getIteratorFn} from 'shared/ReactSymbols';
7676
import {
7777
getCurrentFiberOwnerNameInDevOrNull,
78-
getCurrentFiberStackInDev,
7978
setIsRendering,
8079
} from './ReactCurrentFiber';
8180
import {startWorkTimer, cancelWorkTimer} from './ReactDebugFiberPerf';
@@ -296,7 +295,6 @@ function updateForwardRef(
296295
nextProps, // Resolved props
297296
'prop',
298297
getComponentName(Component),
299-
getCurrentFiberStackInDev,
300298
);
301299
}
302300
}
@@ -414,7 +412,6 @@ function updateMemoComponent(
414412
nextProps, // Resolved props
415413
'prop',
416414
getComponentName(type),
417-
getCurrentFiberStackInDev,
418415
);
419416
}
420417
}
@@ -442,7 +439,6 @@ function updateMemoComponent(
442439
nextProps, // Resolved props
443440
'prop',
444441
getComponentName(type),
445-
getCurrentFiberStackInDev,
446442
);
447443
}
448444
}
@@ -501,7 +497,6 @@ function updateSimpleMemoComponent(
501497
nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
502498
'prop',
503499
getComponentName(outerMemoType),
504-
getCurrentFiberStackInDev,
505500
);
506501
}
507502
// Inner propTypes will be validated in the function component path.
@@ -626,7 +621,6 @@ function updateFunctionComponent(
626621
nextProps, // Resolved props
627622
'prop',
628623
getComponentName(Component),
629-
getCurrentFiberStackInDev,
630624
);
631625
}
632626
}
@@ -793,7 +787,6 @@ function updateClassComponent(
793787
nextProps, // Resolved props
794788
'prop',
795789
getComponentName(Component),
796-
getCurrentFiberStackInDev,
797790
);
798791
}
799792
}
@@ -1198,7 +1191,6 @@ function mountLazyComponent(
11981191
resolvedProps, // Resolved for outer only
11991192
'prop',
12001193
getComponentName(Component),
1201-
getCurrentFiberStackInDev,
12021194
);
12031195
}
12041196
}
@@ -2622,13 +2614,7 @@ function updateContextProvider(
26222614
const providerPropTypes = workInProgress.type.propTypes;
26232615

26242616
if (providerPropTypes) {
2625-
checkPropTypes(
2626-
providerPropTypes,
2627-
newProps,
2628-
'prop',
2629-
'Context.Provider',
2630-
getCurrentFiberStackInDev,
2631-
);
2617+
checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider');
26322618
}
26332619
}
26342620

@@ -3208,7 +3194,6 @@ function beginWork(
32083194
resolvedProps, // Resolved for outer only
32093195
'prop',
32103196
getComponentName(type),
3211-
getCurrentFiberStackInDev,
32123197
);
32133198
}
32143199
}

packages/react-reconciler/src/ReactFiberContext.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ import {disableLegacyContext} from 'shared/ReactFeatureFlags';
1515
import {ClassComponent, HostRoot} from 'shared/ReactWorkTags';
1616
import getComponentName from 'shared/getComponentName';
1717
import invariant from 'shared/invariant';
18-
import checkPropTypes from 'prop-types/checkPropTypes';
18+
import checkPropTypes from 'shared/checkPropTypes';
1919

20-
import {getCurrentFiberStackInDev} from './ReactCurrentFiber';
2120
import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf';
2221
import {createCursor, push, pop} from './ReactFiberStack';
2322

@@ -105,13 +104,7 @@ function getMaskedContext(
105104

106105
if (__DEV__) {
107106
const name = getComponentName(type) || 'Unknown';
108-
checkPropTypes(
109-
contextTypes,
110-
context,
111-
'context',
112-
name,
113-
getCurrentFiberStackInDev,
114-
);
107+
checkPropTypes(contextTypes, context, 'context', name);
115108
}
116109

117110
// Cache unmasked context so we can avoid recreating masked context unless necessary.
@@ -223,18 +216,7 @@ function processChildContext(
223216
}
224217
if (__DEV__) {
225218
const name = getComponentName(type) || 'Unknown';
226-
checkPropTypes(
227-
childContextTypes,
228-
childContext,
229-
'child context',
230-
name,
231-
// In practice, there is one case in which we won't get a stack. It's when
232-
// somebody calls unstable_renderSubtreeIntoContainer() and we process
233-
// context from the parent component instance. The stack will be missing
234-
// because it's outside of the reconciliation, and so the pointer has not
235-
// been set. This is rare and doesn't matter. We'll also remove that API.
236-
getCurrentFiberStackInDev,
237-
);
219+
checkPropTypes(childContextTypes, childContext, 'child context', name);
238220
}
239221

240222
return {...parentContext, ...childContext};

0 commit comments

Comments
 (0)