Skip to content

Instantly share code, notes, and snippets.

@cacheflow
Last active January 22, 2016 02:20
Show Gist options
  • Save cacheflow/15cc856680bb42117b01 to your computer and use it in GitHub Desktop.
Save cacheflow/15cc856680bb42117b01 to your computer and use it in GitHub Desktop.
renderFirstQuestion() {
let answers = Object.keys(this.state.questions[0].answers)
let images = this.state.questions[0].images
let renderImages = Object.keys(images).map((image, index) => {
return (
<div>
<FirstQuestion
key={images[image] + index}
imgSrc={images[image]} />
</div>
)
})
let renderedFirstQuestion = answers.map((answer, index) =>{
return (
<FirstQuestion
key = {index + this.state.questions[0].question}
findAnswer={this.findAnswer.bind(this)}
updatePage={this.updatePageState.bind(this)}
images = {this.state.questions[0].images}
answer={answer}
/>
)
})
return (
<div>
{this.state.questions[0].question}
{renderImages}
{renderedFirstQuestion}
</div>
)
}
export default class FirstQuestion extends React.Component {
render() {
return (
<div>
<button onClick={() => this.props.findAnswer(this.props.answer)}>
{this.props.answer}
</button>
<img className={styles.imgSize} src={this.props.imgSrc} />
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment