GridSheet's architecture is built on the relationship between a Registry and Sheet instances.
- Registry: A cross-cutting instance (accessed via a
Book) shared across multiple sheets. It acts as a central hub for Functions, Policies, History (undo/redo), Async Cache, and Event Handlers. - Sheet: A specific instance corresponding to a rendered
<GridSheet> component. It manages its own ID Matrix, Cell Data, System Metadata, and Sheet State.
Key Pattern: The Book Wrapper
A Book is a thin wrapper { registry: Registry } created using useBook() (React hook) or createBook() (imperative). This allows React to trigger re-renders by replacing the Book reference while the underlying Registry maintains a stable identity.
Note: If you do not provide an explicit book prop to a <GridSheet>, a new Registry is implicitly created for that single sheet. To share state, functions, or history across multiple sheets, you must create one Book and pass it to all relevant <GridSheet> components.
// Example of sharing a registry across multiple sheets
const book = useBook();
return (
<>
<GridSheet sheetName="Sheet1" book={book} />
<GridSheet sheetName="Sheet2" book={book} />
</>
);