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

Combined two if statements that do the same things in many places in the ReactFreshRuntime.js file #28757

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
19 changes: 8 additions & 11 deletions packages/react-refresh/src/ReactFreshRuntime.js
Expand Up @@ -192,10 +192,7 @@ export function performReactRefresh(): RefreshUpdate | null {
'Unexpected call to React Refresh in a production environment.',
);
}
if (pendingUpdates.length === 0) {
return null;
}
if (isPerformingRefresh) {
if (pendingUpdates.length === 0 || isPerformingRefresh) {
return null;
}

Expand Down Expand Up @@ -698,13 +695,13 @@ export function isLikelyComponentType(type: any): boolean {
return true;
}
const ownNames = Object.getOwnPropertyNames(type.prototype);
if (ownNames.length > 1 || ownNames[0] !== 'constructor') {
// This looks like a class.
return false;
}
// eslint-disable-next-line no-proto
if (type.prototype.__proto__ !== Object.prototype) {
// It has a superclass.
if (
ownNames.length > 1 ||
ownNames[0] !== 'constructor' ||
// eslint-disable-next-line no-proto
type.prototype.__proto__ !== Object.prototype
) {
// This looks like a class or it has a superclass.
return false;
}
// Pass through.
Expand Down