@@ -144,13 +144,15 @@ const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
144
144
let didReceiveUpdate : boolean = false ;
145
145
146
146
let didWarnAboutBadClass ;
147
+ let didWarnAboutModulePatternComponent ;
147
148
let didWarnAboutContextTypeOnFunctionComponent ;
148
149
let didWarnAboutGetDerivedStateOnFunctionComponent ;
149
150
let didWarnAboutFunctionRefs ;
150
151
export let didWarnAboutReassigningProps ;
151
152
152
153
if ( __DEV__ ) {
153
154
didWarnAboutBadClass = { } ;
155
+ didWarnAboutModulePatternComponent = { } ;
154
156
didWarnAboutContextTypeOnFunctionComponent = { } ;
155
157
didWarnAboutGetDerivedStateOnFunctionComponent = { } ;
156
158
didWarnAboutFunctionRefs = { } ;
@@ -1222,6 +1224,24 @@ function mountIndeterminateComponent(
1222
1224
typeof value . render === 'function' &&
1223
1225
value . $$typeof === undefined
1224
1226
) {
1227
+ if ( __DEV__ ) {
1228
+ const componentName = getComponentName ( Component ) || 'Unknown' ;
1229
+ if ( ! didWarnAboutModulePatternComponent [ componentName ] ) {
1230
+ warningWithoutStack (
1231
+ false ,
1232
+ 'The <%s /> component appears to be a function component that returns a class instance. ' +
1233
+ 'Change %s to a class that extends React.Component instead. ' +
1234
+ "If you can't use a class try assigning the prototype on the function as a workaround. " +
1235
+ "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " +
1236
+ 'cannot be called with `new` by React.' ,
1237
+ componentName ,
1238
+ componentName ,
1239
+ componentName ,
1240
+ ) ;
1241
+ didWarnAboutModulePatternComponent [ componentName ] = true ;
1242
+ }
1243
+ }
1244
+
1225
1245
// Proceed under the assumption that this is a class instance
1226
1246
workInProgress . tag = ClassComponent ;
1227
1247
0 commit comments