-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
react v15.5.4 warning #5705
Comments
Hey @39Er! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
These warnings are not Babel related, they are just warnings that React itself shows because you are using features that React is changing. |
Oh,I see ,thank U |
I do think it's related to Babel. React implements the following check in order to trigger warnings for every access to the Object.defineProperty(React, 'PropTypes', {
get: function() {
lowPriorityWarning(didWarnPropTypesDeprecated, 'Accessing PropTypes via the main React package is deprecated,' + ' and will be removed in React v16.0.' + ' Use the latest available v15.* prop-types package from npm instead.' + ' For info on usage, compatibility, migration and more, see ' + 'https://fb.me/prop-types-docs');
didWarnPropTypesDeprecated = true;
return ReactPropTypes;
}
}); As you can see below because Babel iterates over all properties in the React object, it reads the function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key))
newObj[key] = obj[key];
}
}
newObj.default = obj;
return newObj;
}
} |
This shouldn't be Babel. Try this: const React = {};
Object.defineProperty(React, 'PropTypes', {
get: function() {
throw new Error('PropTypes');
}
});
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key))
newObj[key] = obj[key];
}
}
newObj.default = obj;
return newObj;
}
}
_interopRequireWildcard(React); |
FTR It's been fixed in #6850 |
I used babel-preset-react,but it shows the follow warning:
node.js v4.4.5
react v15.5.4
babel 6.24.0
The text was updated successfully, but these errors were encountered: