Home / Class/ LifeCycleComponent Class — react Architecture

LifeCycleComponent Class — react Architecture

Architecture documentation for the LifeCycleComponent class in ReactComponentLifeCycle-test.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  7525ab1d_f63f_1b70_472a_5ab791a0b627["LifeCycleComponent"]
  a5334318_ba5d_d1e3_5be5_45cbc1076fcf["ReactComponentLifeCycle-test.js"]
  7525ab1d_f63f_1b70_472a_5ab791a0b627 -->|defined in| a5334318_ba5d_d1e3_5be5_45cbc1076fcf
  d0c9fc7d_9d4d_1cdb_f22b_922d3e78f346["constructor()"]
  7525ab1d_f63f_1b70_472a_5ab791a0b627 -->|method| d0c9fc7d_9d4d_1cdb_f22b_922d3e78f346
  78c4cfa6_5e8d_bdbc_f0d8_06fb87df4e80["UNSAFE_componentWillMount()"]
  7525ab1d_f63f_1b70_472a_5ab791a0b627 -->|method| 78c4cfa6_5e8d_bdbc_f0d8_06fb87df4e80
  eb288bf2_8ea9_0429_3935_340cf6ef04c9["componentDidMount()"]
  7525ab1d_f63f_1b70_472a_5ab791a0b627 -->|method| eb288bf2_8ea9_0429_3935_340cf6ef04c9
  43df8f94_7b9e_7101_f1b9_8a66626f5a2f["render()"]
  7525ab1d_f63f_1b70_472a_5ab791a0b627 -->|method| 43df8f94_7b9e_7101_f1b9_8a66626f5a2f
  a41d53af_d96d_c003_c426_717520e34c8a["componentWillUnmount()"]
  7525ab1d_f63f_1b70_472a_5ab791a0b627 -->|method| a41d53af_d96d_c003_c426_717520e34c8a

Relationship Graph

Source Code

packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js lines 274–314

    class LifeCycleComponent extends React.Component {
      constructor(props, context) {
        super(props, context);
        this._testJournal = {};
        const initState = {
          hasWillMountCompleted: false,
          hasDidMountCompleted: false,
          hasRenderCompleted: false,
          hasWillUnmountCompleted: false,
        };
        this._testJournal.returnedFromGetInitialState = clone(initState);
        this.state = initState;
      }

      UNSAFE_componentWillMount() {
        this._testJournal.stateAtStartOfWillMount = clone(this.state);
        this.state.hasWillMountCompleted = true;
      }

      componentDidMount() {
        this._testJournal.stateAtStartOfDidMount = clone(this.state);
        this.setState({hasDidMountCompleted: true});
      }

      render() {
        const isInitialRender = !this.state.hasRenderCompleted;
        if (isInitialRender) {
          this._testJournal.stateInInitialRender = clone(this.state);
        } else {
          this._testJournal.stateInLaterRender = clone(this.state);
        }
        // you would *NEVER* do anything like this in real code!
        this.state.hasRenderCompleted = true;
        return <div ref={React.createRef()}>I am the inner DIV</div>;
      }

      componentWillUnmount() {
        this._testJournal.stateAtStartOfWillUnmount = clone(this.state);
        this.state.hasWillUnmountCompleted = true;
      }
    }

Frequently Asked Questions

What is the LifeCycleComponent class?
LifeCycleComponent is a class in the react codebase, defined in packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js.
Where is LifeCycleComponent defined?
LifeCycleComponent is defined in packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js at line 274.

Analyze Your Own Codebase

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

Try Supermodel Free