-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdefault.page.tsx
More file actions
50 lines (44 loc) · 1001 Bytes
/
default.page.tsx
File metadata and controls
50 lines (44 loc) · 1001 Bytes
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
39
40
41
42
43
44
45
46
47
48
49
50
import * as React from 'react';
import {
DataSource,
useDataSourceSelector,
} from '@infinite-table/infinite-react';
interface Person {
name: string;
age: number;
id: string | number;
}
const persons: Person[] = [
{ name: 'bob', age: 1, id: 1 },
{ name: 'bill', age: 2, id: 2 },
];
const Cmp = () => {
const { dataArray, loading } = useDataSourceSelector((ctx) => {
return {
dataArray: ctx.dataSourceState.dataArray,
loading: ctx.dataSourceState.loading,
};
});
return (
<div aria-label="container" style={{ color: 'tomato' }}>
{loading ? 'loading' : null}
{loading ? null : JSON.stringify(dataArray)}
</div>
);
};
const personsPromise: Promise<Person[]> = new Promise((resolve) => {
setTimeout(() => {
resolve(persons);
}, 200);
});
export default () => {
return (
<DataSource<Person>
data={personsPromise}
primaryKey="id"
fields={['name', 'id', 'age']}
>
<Cmp />
</DataSource>
);
};