Skip to content

Instantly share code, notes, and snippets.

@lizdenhup
Created September 25, 2017 00:34
Show Gist options
  • Save lizdenhup/bbded8b7656e918e54d7607461b20efd to your computer and use it in GitHub Desktop.
Save lizdenhup/bbded8b7656e918e54d7607461b20efd to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import Candidate from './Candidate.js';
import Button from 'react-uikit-button';
export default class CandidateList extends Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this)
}
handleClick() {
this.props.onClick(this.props.votes)
}
render() {
if (this.props.candidates !== null) {
var candidateItems = this.props.candidates.map((candidate) => (
<Candidate
key={'candidate-' + candidate.id}
id={candidate.id}
name={candidatecandidate[0]}
/>
));
return (
<div>
{candidateItems}
<Button
block body='Vote for me!'
context='primary'
onClick={this.handleClick} />
</div>
)} else {
return (
null
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment