Last active
January 22, 2016 02:20
-
-
Save cacheflow/15cc856680bb42117b01 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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> | |
) | |
} |
This file contains hidden or 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
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