Extension of SpreadsheetData interface so that it's compatible with React's useSyncExternalStore hook

Additional properties are optional, so anything that implements SpreadsheetData is compatible with something that accepts ReactSpreadsheetData.

interface ReactSpreadsheetData<Snapshot> {
    getServerSnapshot?: () => Snapshot;
    getCellFormat(
        snapshot: Snapshot,
        row: number,
        column: number,
    ): undefined | string;
    getCellValue(snapshot: Snapshot, row: number, column: number): CellValue;
    getColumnCount(snapshot: Snapshot): number;
    getColumnItemOffsetMapping(snapshot: Snapshot): ItemOffsetMapping;
    getRowCount(snapshot: Snapshot): number;
    getRowItemOffsetMapping(snapshot: Snapshot): ItemOffsetMapping;
    getSnapshot(): Snapshot;
    setCellValueAndFormat(
        row: number,
        column: number,
        value: CellValue,
        format: undefined | string,
    ): boolean;
    subscribe(onDataChange: () => void): () => void;
}

Type Parameters

  • Snapshot

Hierarchy (View Summary)

Methods

Properties

getServerSnapshot?: () => Snapshot

Used by useSyncExternalStore to support server side rendering