react for dummies..

This commit is contained in:
Sander Hautvast 2018-07-18 16:13:42 +02:00
parent bd1ee0cfe9
commit 77404d0be6

View file

@ -10,11 +10,12 @@ class Tree extends Component {
} }
loadData() { loadData() {
console.log(this);
axios.get("http://localhost:2048/callstack") axios.get("http://localhost:2048/callstack")
.then(response => this.setState({ data: response.data })); .then(response => this.setState({ data: response.data }));
} }
clear() { clearData() {
axios.get("http://localhost:2048/clear") axios.get("http://localhost:2048/clear")
.then(response => this.setState({ data: response.data })); .then(response => this.setState({ data: response.data }));
} }
@ -36,8 +37,8 @@ class Tree extends Component {
render() { render() {
return ( return (
<div> <div>
<button type="button" onClick={this.clear}>clear</button> <button type="button" onClick={() => this.clearData()}>clear</button>
<button type="button" onClick={this.loadData}>refresh</button> <button type="button" onClick={() => this.loadData()}>refresh</button>
<div className="view"><h1>Callstack view</h1> <div className="view"><h1>Callstack view</h1>
<div className="treeView"> <div className="treeView">
{this.renderChildren(this.state.data)} {this.renderChildren(this.state.data)}