import React from 'react'; import PureRenderMixin from 'react-addons-pure-render-mixin'; import {connect} from 'react-redux'; import Winner from './Winner'; import * as actionCreators from '../action_creators'; export const VOTE_WIDTH_PERCENT = 8; export const Results = React.createClass({ mixins: [PureRenderMixin], getPair: function () { return this.props.pair || []; }, getVotes: function(entry) { if (this.props.tally && this.props.tally.has(entry)) { return this.props.tally.get(entry); } return 0; }, getVotesBlockWidth: function(entry) { console.log(entry); console.log(this.getVotes(entry)); return (this.getVotes(entry) * VOTE_WIDTH_PERCENT) + '%'; }, render: function () { return this.props.winner ? :
{this.getPair().map(entry =>

{entry}

{this.getVotes(entry)}
)}
; } }); function mapStateToProps(state) { return { pair: state.getIn(['vote', 'pair']), tally: state.getIn(['vote', 'tally']), winner: state.get('winner') } } export const ResultsContainer = connect(mapStateToProps, actionCreators)(Results);