Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depend on prop-types/checkPropTypes, not prop-types itself #11420

Merged
merged 3 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactDOMInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ describe('ReactDOMInput', () => {
);
expectDev(console.error.calls.count()).toBe(1);
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Failed form propType: You provided a `value` prop to a form ' +
'Warning: Failed prop type: You provided a `value` prop to a form ' +
'field without an `onChange` handler. This will render a read-only ' +
'field. If the field should be mutable use `defaultValue`. ' +
'Otherwise, set either `onChange` or `readOnly`.\n' +
Expand Down
30 changes: 2 additions & 28 deletions packages/react-dom/src/shared/ReactControlledValuePropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ var ReactControlledValuePropTypes = {
};

if (__DEV__) {
var warning = require('fbjs/lib/warning');
var emptyFunction = require('fbjs/lib/emptyFunction');
var PropTypes = require('prop-types');
var checkPropTypes = require('prop-types/checkPropTypes');

var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';

ReactControlledValuePropTypes.checkPropTypes = emptyFunction;
var hasReadOnlyValue = {
button: true,
checkbox: true,
Expand Down Expand Up @@ -63,11 +58,8 @@ if (__DEV__) {
'set either `onChange` or `readOnly`.',
);
},
onChange: PropTypes.func,
};

var loggedTypeFailures = {};

/**
* Provide a linked `value` attribute for controlled forms. You should not use
* this outside of the ReactDOM controlled form components.
Expand All @@ -77,25 +69,7 @@ if (__DEV__) {
props,
getStack,
) {
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
var error = propTypes[propName](
props,
propName,
tagName,
'prop',
null,
ReactPropTypesSecret,
);
}
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
// Only monitor this failure once because there tends to be a lot of the
// same error.
loggedTypeFailures[error.message] = true;

warning(false, 'Failed form propType: %s%s', error.message, getStack());
}
}
checkPropTypes(propTypes, props, 'prop', tagName, getStack);
};
}

Expand Down
28 changes: 14 additions & 14 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
"gzip": 6776
},
"react-dom.development.js (UMD_DEV)": {
"size": 629993,
"gzip": 144537
"size": 609118,
"gzip": 139930
},
"react-dom.production.min.js (UMD_PROD)": {
"size": 101759,
"gzip": 31837
},
"react-dom.development.js (NODE_DEV)": {
"size": 594328,
"gzip": 136213
"size": 593556,
"gzip": 135968
},
"react-dom.production.min.js (NODE_PROD)": {
"size": 107772,
"gzip": 33333
},
"ReactDOM-dev.js (FB_DEV)": {
"size": 594288,
"gzip": 136503
"size": 593516,
"gzip": 136258
},
"ReactDOM-prod.js (FB_PROD)": {
"size": 422865,
Expand Down Expand Up @@ -85,32 +85,32 @@
"gzip": 15630
},
"react-dom-server.browser.development.js (UMD_DEV)": {
"size": 126953,
"gzip": 32659
"size": 106084,
"gzip": 27905
},
"react-dom-server.browser.production.min.js (UMD_PROD)": {
"size": 15612,
"gzip": 6067
},
"react-dom-server.browser.development.js (NODE_DEV)": {
"size": 96840,
"gzip": 25434
"size": 96070,
"gzip": 25231
},
"react-dom-server.browser.production.min.js (NODE_PROD)": {
"size": 15340,
"gzip": 5985
},
"ReactDOMServer-dev.js (FB_DEV)": {
"size": 96316,
"gzip": 25374
"size": 95546,
"gzip": 25176
},
"ReactDOMServer-prod.js (FB_PROD)": {
"size": 43775,
"gzip": 12037
},
"react-dom-server.node.development.js (NODE_DEV)": {
"size": 99113,
"gzip": 25973
"size": 98343,
"gzip": 25770
},
"react-dom-server.node.production.min.js (NODE_PROD)": {
"size": 16264,
Expand Down