-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo2.js
29 lines (24 loc) · 801 Bytes
/
demo2.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
import React, {Component } from 'react'
import TreeView, {testdata} from './tree.js'
// Demonstrate the treeview, basic tree + add/remove parts.
export default class Demo2 extends Component {
// Here, we need to fetch data from server.
constructor(props) {
super(props);
this.state = {contents: testdata};
}
// The contents has been changed somehow, update server.
onChange(contents) {
console.log("New contents: %o", contents);
}
render() {
const onChange = function(c) {this.setState({contents: c}); }.bind(this);
return (
<div className="TreeviewDemo">
<TreeView
contents={this.state.contents}
onChange={onChange} />
</div>
);
}
}