-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42bcfc6
commit f6c8c35
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
var React = require('react'); | ||
var Api = require('../utils/api'); | ||
|
||
module.exports = React.createClass({ | ||
getInitialState: function() { | ||
return { | ||
topics: [] | ||
} | ||
}, | ||
componentWillMount: function() { | ||
Api.get('topics/defaults') | ||
.then(function(data){ | ||
this.setState({ | ||
topics: data.data | ||
}) | ||
}.bind(this)); | ||
}, | ||
render: function() { | ||
return <div className="list-group"> | ||
Topic List | ||
{this.renderTopics()} | ||
</div> | ||
}, | ||
renderTopics: function() { | ||
return this.state.topics.map(function(topic){ | ||
return <li> | ||
{topic} | ||
</li> | ||
}); | ||
} | ||
}) | ||
}); |
f6c8c35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncaught (in promise) TypeError: Cannot read property 'data' of undefined(…)
It seems like data is not defined here. Do you have to pass data as a parameter in componentWillMount function?