Home / Class/ SuspendyTree Class — react Architecture

SuspendyTree Class — react Architecture

Architecture documentation for the SuspendyTree class in index.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  0eadbd23_32a8_5a62_5874_e3f89e2fd459["SuspendyTree"]
  bc541b6e_9521_11e1_5e2b_622a6b2d721e["index.js"]
  0eadbd23_32a8_5a62_5874_e3f89e2fd459 -->|defined in| bc541b6e_9521_11e1_5e2b_622a6b2d721e
  f4e5d882_7ba9_1d96_c1dd_0d27c6fa3c7a["componentDidMount()"]
  0eadbd23_32a8_5a62_5874_e3f89e2fd459 -->|method| f4e5d882_7ba9_1d96_c1dd_0d27c6fa3c7a
  7152457a_0c87_b59d_5f3e_19b27d04b98e["componentWillUnmount()"]
  0eadbd23_32a8_5a62_5874_e3f89e2fd459 -->|method| 7152457a_0c87_b59d_5f3e_19b27d04b98e
  f765f743_9b21_7861_ddf0_181676d13f00["render()"]
  0eadbd23_32a8_5a62_5874_e3f89e2fd459 -->|method| f765f743_9b21_7861_ddf0_181676d13f00

Relationship Graph

Source Code

fixtures/dom/src/components/fixtures/suspense/index.js lines 62–107

class SuspendyTree extends React.Component {
  parentContainer = React.createRef(null);
  container = React.createRef(null);
  componentDidMount() {
    this.setState({});
    document.addEventListener('keydown', this.onKeydown);
  }
  componentWillUnmount() {
    document.removeEventListener('keydown', this.onKeydown);
  }
  onKeydown = event => {
    if (event.metaKey && event.key === '/') {
      this.removeAndRestore();
    }
  };
  removeAndRestore = () => {
    const parentContainer = this.parentContainer.current;
    const container = this.container.current;
    parentContainer.removeChild(container);
    parentContainer.textContent = '(removed from DOM)';
    setTimeout(() => {
      parentContainer.textContent = '';
      parentContainer.appendChild(container);
    }, 500);
  };
  render() {
    return (
      <>
        <div ref={this.parentContainer}>
          <div ref={this.container} />
        </div>
        <div>
          {this.container.current !== null
            ? ReactDOM.createPortal(
                <>
                  <SuspendyTreeChild>{this.props.children}</SuspendyTreeChild>
                  <button onClick={this.removeAndRestore}>Remove</button>
                </>,
                this.container.current
              )
            : null}
        </div>
      </>
    );
  }
}

Domain

Frequently Asked Questions

What is the SuspendyTree class?
SuspendyTree is a class in the react codebase, defined in fixtures/dom/src/components/fixtures/suspense/index.js.
Where is SuspendyTree defined?
SuspendyTree is defined in fixtures/dom/src/components/fixtures/suspense/index.js at line 62.

Analyze Your Own Codebase

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

Try Supermodel Free