Home / Function/ _findClosestSnapshot() — react Function Reference

_findClosestSnapshot() — react Function Reference

Architecture documentation for the _findClosestSnapshot() function in SnapshotsView.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  163e5c39_dcbb_032a_57e9_b189e6dff0f8["_findClosestSnapshot()"]
  b81cc0fe_3212_0d53_b9ee_a5cdac317703["SnapshotsView"]
  163e5c39_dcbb_032a_57e9_b189e6dff0f8 -->|defined in| b81cc0fe_3212_0d53_b9ee_a5cdac317703
  31e43d15_7c69_dff1_b9a7_17416bef00f6["draw()"]
  31e43d15_7c69_dff1_b9a7_17416bef00f6 -->|calls| 163e5c39_dcbb_032a_57e9_b189e6dff0f8
  64022f73_edf0_3924_f2bc_fa1721df6b4c["_updateHover()"]
  64022f73_edf0_3924_f2bc_fa1721df6b4c -->|calls| 163e5c39_dcbb_032a_57e9_b189e6dff0f8
  6fe722ba_3051_6ecf_abe3_62a190c3ad25["positioningScaleFactor()"]
  163e5c39_dcbb_032a_57e9_b189e6dff0f8 -->|calls| 6fe722ba_3051_6ecf_abe3_62a190c3ad25
  83465e3e_5308_9ddc_a12b_a84d78f1c10a["timestampToPosition()"]
  163e5c39_dcbb_032a_57e9_b189e6dff0f8 -->|calls| 83465e3e_5308_9ddc_a12b_a84d78f1c10a
  style 163e5c39_dcbb_032a_57e9_b189e6dff0f8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-timeline/src/content-views/SnapshotsView.js lines 195–223

  _findClosestSnapshot(x: number): Snapshot | null {
    const frame = this.frame;
    const scaleFactor = positioningScaleFactor(
      this._intrinsicSize.width,
      frame,
    );

    const snapshots = this._profilerData.snapshots;

    let startIndex = 0;
    let stopIndex = snapshots.length - 1;
    while (startIndex <= stopIndex) {
      const currentIndex = Math.floor((startIndex + stopIndex) / 2);
      const snapshot = snapshots[currentIndex];
      const {timestamp} = snapshot;

      const snapshotX = Math.floor(
        timestampToPosition(timestamp, scaleFactor, frame),
      );

      if (x < snapshotX) {
        stopIndex = currentIndex - 1;
      } else {
        startIndex = currentIndex + 1;
      }
    }

    return snapshots[stopIndex] || null;
  }

Domain

Subdomains

Frequently Asked Questions

What does _findClosestSnapshot() do?
_findClosestSnapshot() is a function in the react codebase, defined in packages/react-devtools-timeline/src/content-views/SnapshotsView.js.
Where is _findClosestSnapshot() defined?
_findClosestSnapshot() is defined in packages/react-devtools-timeline/src/content-views/SnapshotsView.js at line 195.
What does _findClosestSnapshot() call?
_findClosestSnapshot() calls 2 function(s): positioningScaleFactor, timestampToPosition.
What calls _findClosestSnapshot()?
_findClosestSnapshot() is called by 2 function(s): _updateHover, draw.

Analyze Your Own Codebase

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

Try Supermodel Free