Integrate Sheetwrite with React ownership, readiness, and controlled resets.
@sheetwrite/react initializes WASM after client mount. Use Sheetwrite for the simple columns and defaultRows contract; use SheetwriteGrid when the host supplies a Workbook plus eager data or a datasource.
onGridChange reports committed grid changes. onReady receives { grid, generation, reason } after the forwarded ref is assigned. Replacing reset-sensitive inputs creates a new generation; destroy persistence/sync coordinators attached to the previous grid.
React adapter
import { Sheetwriteconst Sheetwrite: <Row extends Record<string, CellScalar>>(props: SheetwriteProps<Row> & {
ref?: ForwardedRef<Grid>;
}) => ReactElementconstSheetwrite: <RowextendsRecord<string, CellScalar>>(props:SheetwriteProps<Row> & {ref?:ForwardedRef<Grid>;},) =>ReactElementconstSheetwrite: <RowextendsRecord<string,CellScalar>,>(props:SheetwriteProps<Row> & {ref?:ForwardedRef<Grid>;},) =>ReactElementConvenience component for local object rows. It derives a single-sheet workbook from columns, defaultRows, and sheetName, initializes Sheetwrite, and owns the Grid through prop-driven resets and unmount cleanup. Pass a ref to access the live Grid; use SheetwriteGrid when the host already owns a workbook or datasource.API reference →, typeGridReadyEventinterface GridReadyEventinterfaceGridReadyEventinterfaceGridReadyEventGrid handle, generation, and reason published after adapter initialization.API reference →, typeSimpleColumninterface SimpleColumn<Row extends Record<string, CellScalar>>interfaceSimpleColumn<RowextendsRecord<string, CellScalar>>interfaceSimpleColumn<RowextendsRecord<string, CellScalar>>Column definition accepted by the adapters’ simple row-object API.API reference → } from"@sheetwrite/react";
importtype { Transactioninterface TransactioninterfaceTransactioninterfaceTransactionLow-level Store transaction. epoch provides optional optimistic concurrency at the storage boundary. Calling Store.applyTransaction bypasses Grid read-only checks and Grid undo/redo history. Host-driven edits should use Grid.applyTransaction.API reference → } from"@sheetwrite/core";
saveSheetProps.save: (transaction: Transaction) => voidinterfaceSheetProps {save: (transaction:Transaction) =>void;}interfaceSheetProps {save: (transaction:Transaction,) =>void;}: (transaction:Transactioninterface TransactioninterfaceTransactioninterfaceTransactionLow-level Store transaction. epoch provides optional optimistic concurrency at the storage boundary. Calling Store.applyTransaction bypasses Grid read-only checks and Grid undo/redo history. Host-driven edits should use Grid.applyTransaction.API reference →) =>void;
onReadySheetProps.onReady: (event: GridReadyEvent) => voidinterfaceSheetProps {onReady: (event:GridReadyEvent) =>void;}interfaceSheetProps {onReady: (event:GridReadyEvent,) =>void;}Fires after the adapter publishes a ready Grid generation.API reference →: (event:GridReadyEventinterface GridReadyEventinterfaceGridReadyEventinterfaceGridReadyEventGrid handle, generation, and reason published after adapter initialization.API reference →) =>void;
}
exportfunctionSheetfunction Sheet({ columns, rows, save, onReady }: SheetProps): JSX.ElementfunctionSheet({columns,rows,save,onReady,}:SheetProps):JSX.ElementfunctionSheet({columns,rows,save,onReady,}:SheetProps):JSX.ElementAPI reference →({ columnscolumns: readonly SimpleColumn<Row>[]let columns:readonlySimpleColumn<Row>[]let columns:readonlySimpleColumn<Row>[]Restrict to these column indices (defaults to all columns).API reference →, rowsrows: readonly Row[]let rows:readonlyRow[]let rows:readonlyRow[]end-exclusive row rangeAPI reference →, savesave: (transaction: Transaction) => voidletsave: (transaction:Transaction) =>voidletsave: (transaction:Transaction,) =>void, onReadyonReady: (event: GridReadyEvent) => voidletonReady: (event:GridReadyEvent) =>voidletonReady: (event:GridReadyEvent,) =>voidFires after the adapter publishes a ready Grid generation.API reference → }:SheetPropsinterface SheetPropsinterfaceSheetPropsinterfaceSheetProps) {
return (
<Sheetwriteconst Sheetwrite: <Row extends Record<string, CellScalar>>(props: SheetwriteProps<Row> & {
ref?: ForwardedRef<Grid>;
}) => ReactElementconstSheetwrite: <RowextendsRecord<string, CellScalar>>(props:SheetwriteProps<Row> & {ref?:ForwardedRef<Grid>;},) =>ReactElementconstSheetwrite: <RowextendsRecord<string,CellScalar>,>(props:SheetwriteProps<Row> & {ref?:ForwardedRef<Grid>;},) =>ReactElementConvenience component for local object rows. It derives a single-sheet workbook from columns, defaultRows, and sheetName, initializes Sheetwrite, and owns the Grid through prop-driven resets and unmount cleanup. Pass a ref to access the live Grid; use SheetwriteGrid when the host already owns a workbook or datasource.API reference →
columnscolumns: readonly SimpleColumn<Row>[]let columns:readonlySimpleColumn<Row>[]let columns:readonlySimpleColumn<Row>[]Ordered schema used to derive the component-owned sheet.API reference →={columnscolumns: readonly SimpleColumn<Row>[]let columns:readonlySimpleColumn<Row>[]let columns:readonlySimpleColumn<Row>[]Restrict to these column indices (defaults to all columns).API reference →}