Skip to content

Commit d3f1517

Browse files
committed
chore: update table demo
1 parent d3d2f3c commit d3f1517

File tree

1 file changed

+25
-41
lines changed

1 file changed

+25
-41
lines changed

docs/examples/simple.tsx

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
/* eslint-disable no-console,func-names,react/no-multi-comp */
21
import Table from 'rc-table';
3-
import React from 'react';
2+
import React, { useState } from 'react';
43
import '../../assets/index.less';
54

65
interface RecordType {
@@ -15,44 +14,29 @@ const data = [
1514
{ a: '1333', c: 'eee', d: 2, key: '3' },
1615
];
1716

18-
class Demo extends React.Component {
19-
constructor(props) {
20-
super(props);
21-
22-
this.state = {
23-
count: 0,
24-
};
25-
26-
this.columns = [
27-
{
28-
title: 'title1',
29-
dataIndex: 'a',
30-
render: this.renderColumn,
31-
},
32-
];
33-
}
34-
35-
renderColumn = () => {
36-
return this.state.count;
37-
};
38-
39-
render() {
40-
return (
41-
<>
42-
<button
43-
onClick={() => {
44-
this.setState({
45-
count: this.state.count + 1,
46-
});
47-
}}
48-
>
49-
Click {this.state.count} times
50-
</button>
51-
<Table<RecordType> columns={this.columns} data={data} />
52-
</>
53-
);
54-
}
55-
}
17+
const Demo = () => {
18+
const [count, setCount] = useState(0);
19+
20+
const columns = [
21+
{
22+
title: 'title',
23+
dataIndex: 'a',
24+
render: () => count,
25+
},
26+
];
27+
28+
return (
29+
<>
30+
<button
31+
onClick={() => {
32+
setCount(count => count + 1);
33+
}}
34+
>
35+
Click {count} times
36+
</button>
37+
<Table<RecordType> columns={columns} data={data} />
38+
</>
39+
);
40+
};
5641

5742
export default Demo;
58-
/* eslint-enable */

0 commit comments

Comments
 (0)