Skip to content

Commit f6c8c35

Browse files
committed
Flux - 11 - Fetching Data Naively
1 parent 42bcfc6 commit f6c8c35

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

imgur-client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"react": "^0.13.3",
2121
"react-router": "^1.0.0-beta2",
2222
"reactify": "^1.1.0",
23+
"reflux": "^0.2.8",
2324
"vinyl-source-stream": "^1.1.0",
2425
"watchify": "^2.4.0",
2526
"whatwg-fetch": "^0.9.0"
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
var React = require('react');
2+
var Api = require('../utils/api');
23

34
module.exports = React.createClass({
5+
getInitialState: function() {
6+
return {
7+
topics: []
8+
}
9+
},
10+
componentWillMount: function() {
11+
Api.get('topics/defaults')
12+
.then(function(data){
13+
this.setState({
14+
topics: data.data
15+
})
16+
}.bind(this));
17+
},
418
render: function() {
519
return <div className="list-group">
620
Topic List
21+
{this.renderTopics()}
722
</div>
23+
},
24+
renderTopics: function() {
25+
return this.state.topics.map(function(topic){
26+
return <li>
27+
{topic}
28+
</li>
29+
});
830
}
9-
})
31+
});

0 commit comments

Comments
 (0)