forked from hafizio/fullstack-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnames-list.jsx
More file actions
30 lines (25 loc) · 712 Bytes
/
Copy pathnames-list.jsx
File metadata and controls
30 lines (25 loc) · 712 Bytes
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
var React = require('react'),
model = require('./model.js');
class NamesList extends React.Component {
constructor() {
super()
this.state = {names: {}}
}
componentWillMount() {
this.update()
}
render() {
var names = Object.keys(this.state.names).map(idx => {
return <li key={idx}>{this.state.names[idx].name}</li>
})
return (
<ul>{names}</ul>
)
}
update() {
model.getValue(['names', 'length'])
.then(length => model.get(['names', {from: 0, to: length-1}, 'name']))
.then(response => this.setState({names: response.json.names}))
}
}
module.exports = NamesList