mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Reduce Lookup for Missing Lifecycle Methods
This is a micro-optimization that reduces the lookup time for missing lifecycle methods. The extra amount of memory is linear to the number of components that exist on a page which I think is a worthwile trade-off.
This commit is contained in:
committed by
Paul O’Shannessy
parent
7b68fcd408
commit
8687645c50
@@ -875,6 +875,12 @@ var ReactCompositeComponent = {
|
||||
Constructor.prototype.render,
|
||||
'createClass(...): Class specification must implement a `render` method.'
|
||||
);
|
||||
// Reduce time spent doing lookups by setting these on the prototype.
|
||||
for (var methodName in ReactCompositeComponentInterface) {
|
||||
if (!Constructor.prototype[methodName]) {
|
||||
Constructor.prototype[methodName] = null;
|
||||
}
|
||||
}
|
||||
|
||||
var ConvenienceConstructor = function(props, children) {
|
||||
var instance = new Constructor();
|
||||
|
||||
Reference in New Issue
Block a user