mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Start warning when calling a legacy factory
Let's start warning when a legacy factory is called as a plain function call.
This commit is contained in:
committed by
Paul O’Shannessy
parent
989e6b618e
commit
68b7b82145
@@ -31,12 +31,19 @@ function warnForLegacyFactoryCall() {
|
||||
return;
|
||||
}
|
||||
var owner = ReactCurrentOwner.current;
|
||||
var name = owner && owner.constructor ? owner.constructor.displayName : 'N/A';
|
||||
var name = owner && owner.constructor ? owner.constructor.displayName : '';
|
||||
if (!name) {
|
||||
name = 'Something';
|
||||
}
|
||||
if (legacyFactoryLogs.hasOwnProperty(name)) {
|
||||
return;
|
||||
}
|
||||
legacyFactoryLogs[name] = true;
|
||||
// TODO: Warn for this.
|
||||
warning(
|
||||
false,
|
||||
name + ' is calling a React component directly. ' +
|
||||
'Use a factory or JSX instead. See: http://fb.me/react-legacyfactory'
|
||||
);
|
||||
monitorCodeUse('react_legacy_factory_call', { name: name });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user