-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.jsx
46 lines (41 loc) · 1.01 KB
/
app.jsx
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
import React from 'react'
import ReactDOM from 'react-dom'
import { Tree, Button } from 'antd'
const { DirectoryTree } = Tree
class FolderTree extends React.Component {
constructor (props) {
super(props)
this.state = {
expand_all: true
}
}
onSelect = (keys, event) => {
const key = keys && keys[0]
if (!key) return
console.log(key)
}
trigger_expand = () => {
const {expand_all} = this.state
this.setState({expand_all: !expand_all})
}
render () {
const {expand_all} = this.state
return (
<div>
<Button onClick={this.trigger_expand}>{expand_all ? 'Fold All' : 'Expand All'}</Button>
{expand_all ? <DirectoryTree
key={1}
multiple
defaultExpandAll
onSelect={this.onSelect}
treeData={window.treedata}
/> : <DirectoryTree
key={2}
multiple
onSelect={this.onSelect}
treeData={window.treedata}
/>}
</div>)
}
}
ReactDOM.render(<FolderTree />, document.getElementById('root'))