MCPcopy Create free account
hub / github.com/bvaughn/react-window / createInitialMap

Function createInitialMap

lib/components/list/useDynamicRowHeight.ts:8–21  ·  view source on GitHub ↗
(
  initialRowHeights: ReadonlyMap<number, number> | readonly number[] | undefined
)

Source from the content-addressed store, hash-verified

6import type { DynamicRowHeight } from "./types";
7
8function createInitialMap(
9 initialRowHeights: ReadonlyMap<number, number> | readonly number[] | undefined
10): Map<number, number> {
11 const map = new Map<number, number>();
12 if (initialRowHeights !== undefined) {
13 // Invalid heights would corrupt cached row positions; treat them as unmeasured
14 initialRowHeights.forEach((height: number, index: number) => {
15 if (Number.isFinite(height) && height > 0) {
16 map.set(index, height);
17 }
18 });
19 }
20 return map;
21}
22
23export function useDynamicRowHeight({
24 defaultRowHeight,

Callers 1

useDynamicRowHeightFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected