Skip to content

Instantly share code, notes, and snippets.

@rmdort
Created December 8, 2023 08:13
Show Gist options
  • Save rmdort/a9c41bb6e3615768badaec06c07efefe to your computer and use it in GitHub Desktop.
Save rmdort/a9c41bb6e3615768badaec06c07efefe to your computer and use it in GitHub Desktop.
// Option 1 - With useSpreadsheetState hook
// Calculator has to expose the following functions
/*
getPrecedents,
getPrecedentsFromFormulaString,
getDependents,
getGraphNodes,
*/
export const Spreadsheet = () => {
const { onChange, onFill } = useSpreadsheetState({
disableCalculation: true,
})
return (
<CanvasGrid
onChange={(sheetId, cell, value) => {
// Update local state
onChange()
// Send this value to hyperformula
})
onFill={(sheetId, cell, value) => {
// Update local state
onFill()
// Send this value to hyperformula
})
/>
)
}
// Option 2
Completely headless and your own state management
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment