Created
February 18, 2016 03:56
-
-
Save Jtmaca9/7897f1718e98a51a27a5 to your computer and use it in GitHub Desktop.
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
var React = require('react'); | |
var VoteWords = React.createClass({ | |
getInitialState: function(){ | |
return{ | |
votes: [] | |
} | |
}, | |
componentDidMount: function(){ | |
var self = this; | |
if(self.props.voteWords != self.state.votes){ | |
self.setState({votes: self.props.voteWords}); | |
self.renderVotes(this.state.votes); | |
} | |
}, | |
renderVotes: function(votes){ | |
var v = []; | |
for(words in votes){ | |
v.push(<a className="btn btn-primary">{words.word}<span className="badge">{words.count}</span></a>); | |
} | |
return v; | |
}, | |
render: function(){ | |
return ( | |
<div> | |
{this.renderVotes()} | |
</div> | |
) | |
} | |
}); | |
module.exports = VoteWords; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment