-
Notifications
You must be signed in to change notification settings - Fork 49.1k
Remove createClass #9232
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
Remove createClass #9232
Changes from all commits
5cfaa7c
087fe88
c76a4ea
194b25f
646e786
6b539f2
ce48926
957fbc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,21 +13,21 @@ | |
|
||
var ReactBaseClasses = require('ReactBaseClasses'); | ||
var ReactChildren = require('ReactChildren'); | ||
var ReactClass = require('ReactClass'); | ||
var ReactDOMFactories = require('ReactDOMFactories'); | ||
var ReactElement = require('ReactElement'); | ||
var ReactPropTypes = require('ReactPropTypes'); | ||
var ReactVersion = require('ReactVersion'); | ||
|
||
var onlyChild = require('onlyChild'); | ||
var warning = require('fbjs/lib/warning'); | ||
var checkPropTypes = require('checkPropTypes'); | ||
|
||
var createElement = ReactElement.createElement; | ||
var createFactory = ReactElement.createFactory; | ||
var cloneElement = ReactElement.cloneElement; | ||
|
||
if (__DEV__) { | ||
var warning = require('fbjs/lib/warning'); | ||
var canDefineProperty = require('canDefineProperty'); | ||
var ReactElementValidator = require('ReactElementValidator'); | ||
createElement = ReactElementValidator.createElement; | ||
createFactory = ReactElementValidator.createFactory; | ||
|
@@ -38,20 +38,6 @@ var createMixin = function(mixin) { | |
return mixin; | ||
}; | ||
|
||
if (__DEV__) { | ||
var warnedForCreateMixin = false; | ||
|
||
createMixin = function(mixin) { | ||
warning( | ||
warnedForCreateMixin, | ||
'React.createMixin is deprecated and should not be used. You ' + | ||
'can use this mixin directly instead.', | ||
); | ||
warnedForCreateMixin = true; | ||
return mixin; | ||
}; | ||
} | ||
|
||
var React = { | ||
// Modern | ||
|
||
|
@@ -75,7 +61,6 @@ var React = { | |
// Classic | ||
|
||
PropTypes: ReactPropTypes, | ||
createClass: ReactClass.createClass, | ||
createFactory: createFactory, | ||
createMixin: createMixin, | ||
|
||
|
@@ -96,6 +81,35 @@ if (__DEV__) { | |
ReactComponentTreeHook: require('ReactComponentTreeHook'), | ||
ReactDebugCurrentFrame: require('ReactDebugCurrentFrame'), | ||
}); | ||
|
||
let warnedForCreateMixin = false; | ||
let warnedForCreateClass = false; | ||
|
||
React.createMixin = function(mixin) { | ||
warning( | ||
warnedForCreateMixin, | ||
'React.createMixin is deprecated and should not be used. You ' + | ||
'can use this mixin directly instead.', | ||
); | ||
warnedForCreateMixin = true; | ||
return mixin; | ||
}; | ||
|
||
if (canDefineProperty) { | ||
Object.defineProperty(React, 'createClass', { | ||
get: function() { | ||
warning( | ||
warnedForCreateClass, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about waiting for first call and including the class displayName in the message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do that in 15.5 (I have a separate branch that I haven't pushed to yet) but in 16 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh okay. |
||
'React.createClass is no longer supported. Use a plain JavaScript ' + | ||
"class instead. If you're not yet ready to migrate, " + | ||
'create-react-class is available on npm as a temporary, ' + | ||
'drop-in replacement.', | ||
); | ||
warnedForCreateClass = true; | ||
return undefined; | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = React; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Curious why not move
canDefineProperty
andwarning
require statements into this__DEV__
block so you can get rid of this check? They're only used here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the check there to see if you can use
Object.defineProperty
though?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 Yes, ignore me.