MCPcopy Index your code
hub / github.com/react/react / callComponentWillMount

Function callComponentWillMount

packages/react-server/src/ReactFizzClassComponent.js:544–584  ·  view source on GitHub ↗
(type: any, instance: any)

Source from the content-addressed store, hash-verified

542}
543
544function 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
586function processUpdateQueue(
587 internalInstance: InternalInstance,

Callers 1

mountClassInstanceFunction · 0.70

Calls 4

getComponentNameFromTypeFunction · 0.85
errorMethod · 0.65
componentWillMountMethod · 0.45

Tested by

no test coverage detected