(type: any, instance: any)
| 542 | } |
| 543 | |
| 544 | function callComponentWillMount(type: any, instance: any) { |
| 545 | const oldState = instance.state; |
| 546 | |
| 547 | if (typeof instance.componentWillMount === 'function') { |
| 548 | if (__DEV__) { |
| 549 | if (instance.componentWillMount.__suppressDeprecationWarning !== true) { |
| 550 | const componentName = getComponentNameFromType(type) || 'Unknown'; |
| 551 | |
| 552 | if (!didWarnAboutDeprecatedWillMount[componentName]) { |
| 553 | console.warn( |
| 554 | // keep this warning in sync with ReactStrictModeWarning.js |
| 555 | 'componentWillMount has been renamed, and is not recommended for use. ' + |
| 556 | 'See https://react.dev/link/unsafe-component-lifecycles for details.\n\n' + |
| 557 | '* Move code from componentWillMount to componentDidMount (preferred in most cases) ' + |
| 558 | 'or the constructor.\n' + |
| 559 | '\nPlease update the following components: %s', |
| 560 | componentName, |
| 561 | ); |
| 562 | didWarnAboutDeprecatedWillMount[componentName] = true; |
| 563 | } |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | instance.componentWillMount(); |
| 568 | } |
| 569 | if (typeof instance.UNSAFE_componentWillMount === 'function') { |
| 570 | instance.UNSAFE_componentWillMount(); |
| 571 | } |
| 572 | |
| 573 | if (oldState !== instance.state) { |
| 574 | if (__DEV__) { |
| 575 | console.error( |
| 576 | '%s.componentWillMount(): Assigning directly to this.state is ' + |
| 577 | "deprecated (except inside a component's " + |
| 578 | 'constructor). Use setState instead.', |
| 579 | getComponentNameFromType(type) || 'Component', |
| 580 | ); |
| 581 | } |
| 582 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | function processUpdateQueue( |
| 587 | internalInstance: InternalInstance, |
no test coverage detected