Home / Class/ WrapperTestComponentWithErrorBoundary Class — react Architecture

WrapperTestComponentWithErrorBoundary Class — react Architecture

Architecture documentation for the WrapperTestComponentWithErrorBoundary class in evaluator.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  58a007b3_80d2_0d8b_180c_bddb544cd282["WrapperTestComponentWithErrorBoundary"]
  e04df78a_8312_1a6c_3ce1_ea408e44a1d7["evaluator.ts"]
  58a007b3_80d2_0d8b_180c_bddb544cd282 -->|defined in| e04df78a_8312_1a6c_3ce1_ea408e44a1d7
  e0490286_f707_3e4d_e534_7a6faf9833e4["constructor()"]
  58a007b3_80d2_0d8b_180c_bddb544cd282 -->|method| e0490286_f707_3e4d_e534_7a6faf9833e4
  13a40489_14db_6edb_b62c_74d3112aabfd["getDerivedStateFromError()"]
  58a007b3_80d2_0d8b_180c_bddb544cd282 -->|method| 13a40489_14db_6edb_b62c_74d3112aabfd
  a7c9510c_0804_7d73_60af_0b8f80202491["componentDidUpdate()"]
  58a007b3_80d2_0d8b_180c_bddb544cd282 -->|method| a7c9510c_0804_7d73_60af_0b8f80202491
  d81e0572_43a5_0109_b0bc_3a853972f427["render()"]
  58a007b3_80d2_0d8b_180c_bddb544cd282 -->|method| d81e0572_43a5_0109_b0bc_3a853972f427

Relationship Graph

Source Code

compiler/packages/snap/src/sprout/evaluator.ts lines 64–112

class WrapperTestComponentWithErrorBoundary extends React.Component<
  {fn: any; params: Array<any>},
  {errorFromLastRender: any}
> {
  /**
   * Limit retries of the child component by caching seen errors.
   */
  propsErrorMap: Map<any, any>;
  lastProps: any | null;
  // lastProps: object | null;
  constructor(props: any) {
    super(props);
    this.lastProps = null;
    this.propsErrorMap = new Map<any, any>();
    this.state = {
      errorFromLastRender: NO_ERROR_SENTINEL,
    };
  }
  static getDerivedStateFromError(error: any) {
    // Reschedule a second render that immediately returns the cached error
    return {errorFromLastRender: error};
  }
  override componentDidUpdate() {
    if (this.state.errorFromLastRender !== NO_ERROR_SENTINEL) {
      // Reschedule a third render that immediately returns the cached error
      this.setState({errorFromLastRender: NO_ERROR_SENTINEL});
    }
  }
  override render() {
    if (
      this.state.errorFromLastRender !== NO_ERROR_SENTINEL &&
      this.props === this.lastProps
    ) {
      /**
       * The last render errored, cache the error message to avoid running the
       * test fixture more than once
       */
      const errorMsg = `[[ (exception in render) ${this.state.errorFromLastRender?.toString()} ]]`;
      this.propsErrorMap.set(this.lastProps, errorMsg);
      return errorMsg;
    }
    this.lastProps = this.props;
    const cachedError = this.propsErrorMap.get(this.props);
    if (cachedError != null) {
      return cachedError;
    }
    return React.createElement(WrapperTestComponent, this.props);
  }
}

Domain

Frequently Asked Questions

What is the WrapperTestComponentWithErrorBoundary class?
WrapperTestComponentWithErrorBoundary is a class in the react codebase, defined in compiler/packages/snap/src/sprout/evaluator.ts.
Where is WrapperTestComponentWithErrorBoundary defined?
WrapperTestComponentWithErrorBoundary is defined in compiler/packages/snap/src/sprout/evaluator.ts at line 64.

Analyze Your Own Codebase

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

Try Supermodel Free