(instance: any, ctor: any, newProps: any)
| 311 | } |
| 312 | |
| 313 | function checkClassInstance(instance: any, ctor: any, newProps: any) { |
| 314 | if (__DEV__) { |
| 315 | const name = getComponentNameFromType(ctor) || 'Component'; |
| 316 | const renderPresent = instance.render; |
| 317 | |
| 318 | if (!renderPresent) { |
| 319 | if (ctor.prototype && typeof ctor.prototype.render === 'function') { |
| 320 | console.error( |
| 321 | 'No `render` method found on the %s ' + |
| 322 | 'instance: did you accidentally return an object from the constructor?', |
| 323 | name, |
| 324 | ); |
| 325 | } else { |
| 326 | console.error( |
| 327 | 'No `render` method found on the %s ' + |
| 328 | 'instance: you may have forgotten to define `render`.', |
| 329 | name, |
| 330 | ); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | if ( |
| 335 | instance.getInitialState && |
| 336 | !instance.getInitialState.isReactClassApproved && |
| 337 | !instance.state |
| 338 | ) { |
| 339 | console.error( |
| 340 | 'getInitialState was defined on %s, a plain JavaScript class. ' + |
| 341 | 'This is only supported for classes created using React.createClass. ' + |
| 342 | 'Did you mean to define a state property instead?', |
| 343 | name, |
| 344 | ); |
| 345 | } |
| 346 | if ( |
| 347 | instance.getDefaultProps && |
| 348 | !instance.getDefaultProps.isReactClassApproved |
| 349 | ) { |
| 350 | console.error( |
| 351 | 'getDefaultProps was defined on %s, a plain JavaScript class. ' + |
| 352 | 'This is only supported for classes created using React.createClass. ' + |
| 353 | 'Use a static property to define defaultProps instead.', |
| 354 | name, |
| 355 | ); |
| 356 | } |
| 357 | if (instance.contextType) { |
| 358 | console.error( |
| 359 | 'contextType was defined as an instance property on %s. Use a static ' + |
| 360 | 'property to define contextType instead.', |
| 361 | name, |
| 362 | ); |
| 363 | } |
| 364 | |
| 365 | if (disableLegacyContext) { |
| 366 | if (ctor.childContextTypes && !didWarnAboutChildContextTypes.has(ctor)) { |
| 367 | didWarnAboutChildContextTypes.add(ctor); |
| 368 | console.error( |
| 369 | '%s uses the legacy childContextTypes API which was removed in React 19. ' + |
| 370 | 'Use React.createContext() instead. (https://react.dev/link/legacy-context)', |
no test coverage detected