-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcontent.js
85 lines (79 loc) · 2.02 KB
/
content.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import React, { useState, useEffect } from 'react';
import { Markdown } from 'markdownloader';
import { Table } from 'rsuite';
function scrollIntoView() {
if (location.hash) {
try {
document.querySelector(decodeURIComponent(location.hash)).scrollIntoView();
} catch (error) {
console.error(error);
}
}
}
const Content = () => {
const [showDemo, toggleShow] = useState(false);
const [tableData, setTableData] = useState([]);
useEffect(() => {
setTimeout(() => toggleShow(true), 1000);
const getRow = () => {
let o = {};
Array(100)
.fill(0)
.forEach((v, index) => (o[String(index)] = '--'));
return o;
};
setTimeout(() => {
setTableData(
Array(10)
.fill(0)
.map(getRow)
);
}, 5000);
// const timer = setInterval(() => setTableData(prev => [...prev, getRow]), 2000);
return () => clearInterval(timer);
}, []);
useEffect(() => {
scrollIntoView();
});
return (
<div
style={{
paddingBottom: 100
}}
>
<Markdown>{require('../md/doc.md')}</Markdown>
<br />
<h2>动态更新的 DOM</h2>
{showDemo && <Markdown>{require('../md/demo.md')}</Markdown>}
<br />
<h2>层级二</h2>
<div>
<h3>层级三</h3>
<div>
<h4>层级四</h4>
</div>
</div>
<h2>通过设置 deep 参数,使复杂的 DOM 树不会影响性能</h2>
<div style={{ height: 1000 }}>
<Table
data={tableData}
locale={{
emptyMessage: '请稍等几秒'
}}
>
{Array(100)
.fill(0)
.map((column, index) => {
return (
<Table.Column key={index}>
<Table.HeaderCell>{index}</Table.HeaderCell>
<Table.Cell dataKey={String(index)}>{column}</Table.Cell>
</Table.Column>
);
})}
</Table>
</div>
</div>
);
};
export default Content;