Home / Class/ Surface Class — react Architecture

Surface Class — react Architecture

Architecture documentation for the Surface class in ReactART.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  127019bb_3ae8_a754_e44b_b6cf187f347a["Surface"]
  e064536f_e798_4392_8a3b_fe7d105a0a21["ReactART.js"]
  127019bb_3ae8_a754_e44b_b6cf187f347a -->|defined in| e064536f_e798_4392_8a3b_fe7d105a0a21
  43b41f1b_703b_1b88_a149_c545c59b5898["componentDidMount()"]
  127019bb_3ae8_a754_e44b_b6cf187f347a -->|method| 43b41f1b_703b_1b88_a149_c545c59b5898
  edc7b2c3_d64f_4d1c_2942_98b8da7ee18e["componentDidUpdate()"]
  127019bb_3ae8_a754_e44b_b6cf187f347a -->|method| edc7b2c3_d64f_4d1c_2942_98b8da7ee18e
  cb7bae38_c270_3397_335e_9979651971ab["componentWillUnmount()"]
  127019bb_3ae8_a754_e44b_b6cf187f347a -->|method| cb7bae38_c270_3397_335e_9979651971ab
  dc04d002_8970_aeea_1f00_c9af1508fa29["render()"]
  127019bb_3ae8_a754_e44b_b6cf187f347a -->|method| dc04d002_8970_aeea_1f00_c9af1508fa29

Relationship Graph

Source Code

packages/react-art/src/ReactART.js lines 73–145

class Surface extends React.Component {
  componentDidMount() {
    const {height, width} = this.props;

    this._surface = Mode.Surface(+width, +height, this._tagRef);

    this._mountNode = createContainer(
      this._surface,
      disableLegacyMode ? ConcurrentRoot : LegacyRoot,
      null,
      false,
      false,
      '',
      defaultOnUncaughtError,
      defaultOnCaughtError,
      defaultOnRecoverableError,
      defaultOnDefaultTransitionIndicator,
      null,
    );
    // We synchronously flush updates coming from above so that they commit together
    // and so that refs resolve before the parent life cycles.
    updateContainerSync(this.props.children, this._mountNode, this);
    flushSyncWork();
  }

  componentDidUpdate(prevProps, prevState) {
    const props = this.props;

    if (props.height !== prevProps.height || props.width !== prevProps.width) {
      this._surface.resize(+props.width, +props.height);
    }

    // We synchronously flush updates coming from above so that they commit together
    // and so that refs resolve before the parent life cycles.
    updateContainerSync(this.props.children, this._mountNode, this);
    flushSyncWork();

    if (this._surface.render) {
      this._surface.render();
    }
  }

  componentWillUnmount() {
    // We synchronously flush updates coming from above so that they commit together
    // and so that refs resolve before the parent life cycles.
    updateContainerSync(null, this._mountNode, this);
    flushSyncWork();
  }

  render() {
    // This is going to be a placeholder because we don't know what it will
    // actually resolve to because ART may render canvas, vml or svg tags here.
    // We only allow a subset of properties since others might conflict with
    // ART's properties.
    const props = this.props;

    // TODO: ART's Canvas Mode overrides surface title and cursor
    const Tag = Mode.Surface.tagName;

    return (
      <Tag
        ref={ref => (this._tagRef = ref)}
        accessKey={props.accessKey}
        className={props.className}
        draggable={props.draggable}
        role={props.role}
        style={props.style}
        tabIndex={props.tabIndex}
        title={props.title}
      />
    );
  }
}

Domain

Frequently Asked Questions

What is the Surface class?
Surface is a class in the react codebase, defined in packages/react-art/src/ReactART.js.
Where is Surface defined?
Surface is defined in packages/react-art/src/ReactART.js at line 73.

Analyze Your Own Codebase

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

Try Supermodel Free