Skip to content

Commit

Permalink
fix for typescript (#417)
Browse files Browse the repository at this point in the history
Co-authored-by: AkiraShira <[email protected]>
  • Loading branch information
2 people authored and iddan committed Dec 29, 2024
1 parent 2b6d21c commit 701989c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions website/docs/02-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const App = () => {

The Spreadsheet component accepts the `onChange` prop that is called every time one of the Spreadsheet's cells is changed by the user. You can use it to save the modified data and to react to changes (e.g. validating the modified data, further modifying it, persisting it).

JavaScript (See TypeScript example below):

```javascript
import { useState } from "react";
import Spreadsheet from "react-spreadsheet";
Expand All @@ -81,3 +83,18 @@ const App = () => {
return <Spreadsheet data={data} onChange={setData} />;
};
```

TypeScript:

```typescript
import { useState } from "react";
import Spreadsheet from "react-spreadsheet";

const App = () => {
const [data, setData] = useState<Matrix<CellBase>>([
[{ value: "Vanilla" }, { value: "Chocolate" }, { value: "" }],
[{ value: "Strawberry" }, { value: "Cookies" }, { value: "" }],
]);
return <Spreadsheet data={data} onChange={setData} />;
};
```

0 comments on commit 701989c

Please sign in to comment.