-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.quickstart.tsx
38 lines (31 loc) · 1.02 KB
/
App.quickstart.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React, { useState, useEffect } from 'react';
import { WSCanvas, useWindowSize, WSCanvasColumnClickBehavior } from './lib';
const AppQuickStart: React.FC = () => {
const [rows, setRows] = useState<any[][]>([]);
const winSize = useWindowSize();
const ROWS = 500000;
const COLS = 20;
useEffect(() => {
const _rows = [];
for (let ri = 0; ri < ROWS; ++ri) {
const row = [];
for (let ci = 0; ci < COLS; ++ci) {
row.push("r:" + ri + " c:" + ci);
}
_rows.push(row);
}
setRows(_rows);
}, []);
return <WSCanvas
width={winSize.width} height={winSize.height}
rowsCount={rows.length} colsCount={COLS}
showColNumber={true} showRowNumber={true}
columnClickBehavior={WSCanvasColumnClickBehavior.ToggleSort}
rows={rows}
rowGetCellData={(row, colIdx) => row[colIdx]}
prepareCellDataset={() => rows.slice()}
commitCellDataset={(q) => setRows(q)}
rowSetCellData={(row, colIdx, value) => row[colIdx] = value}
/>;
}
export default AppQuickStart;