Home / Function/ callComponentWillReceiveProps() — react Function Reference

callComponentWillReceiveProps() — react Function Reference

Architecture documentation for the callComponentWillReceiveProps() function in ReactFiberClassComponent.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d83968be_2eaf_cd1b_857b_b74b96d7a349["callComponentWillReceiveProps()"]
  3805476a_1924_0e35_fff7_6afad197a523["ReactFiberClassComponent.js"]
  d83968be_2eaf_cd1b_857b_b74b96d7a349 -->|defined in| 3805476a_1924_0e35_fff7_6afad197a523
  40e9392c_b382_4ef8_9ede_8ac85559673c["resumeMountClassInstance()"]
  40e9392c_b382_4ef8_9ede_8ac85559673c -->|calls| d83968be_2eaf_cd1b_857b_b74b96d7a349
  d93c8e6d_2cc8_2077_fe19_1d954fc83959["updateClassInstance()"]
  d93c8e6d_2cc8_2077_fe19_1d954fc83959 -->|calls| d83968be_2eaf_cd1b_857b_b74b96d7a349
  style d83968be_2eaf_cd1b_857b_b74b96d7a349 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberClassComponent.js lines 728–758

function callComponentWillReceiveProps(
  workInProgress: Fiber,
  instance: any,
  newProps: any,
  nextContext: any,
) {
  const oldState = instance.state;
  if (typeof instance.componentWillReceiveProps === 'function') {
    instance.componentWillReceiveProps(newProps, nextContext);
  }
  if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
    instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
  }

  if (instance.state !== oldState) {
    if (__DEV__) {
      const componentName =
        getComponentNameFromFiber(workInProgress) || 'Component';
      if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
        didWarnAboutStateAssignmentForComponent.add(componentName);
        console.error(
          '%s.componentWillReceiveProps(): Assigning directly to ' +
            "this.state is deprecated (except inside a component's " +
            'constructor). Use setState instead.',
          componentName,
        );
      }
    }
    classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  }
}

Domain

Subdomains

Frequently Asked Questions

What does callComponentWillReceiveProps() do?
callComponentWillReceiveProps() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberClassComponent.js.
Where is callComponentWillReceiveProps() defined?
callComponentWillReceiveProps() is defined in packages/react-reconciler/src/ReactFiberClassComponent.js at line 728.
What calls callComponentWillReceiveProps()?
callComponentWillReceiveProps() is called by 2 function(s): resumeMountClassInstance, updateClassInstance.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free