I have a object that I want to output via React:
question = {
text: "Is this a good question?",
answers: [
"Yes",
"No",
"I don't know"
]
}
and my react component (cut down), is another component
class QuestionSet extends Component {
render(){
<div className="container">
<h1>{this.props.question.text}</h1>
{this.props.question.answers.forEach(answer => {
console.log("Entered"); //This does ifre
<Answer answer={answer} /> //THIS DOES NOT WORK
})}
}
export default QuestionSet;
as you can see from the snippit above, i'm trying to insert an array of the component Answer by using the array Answers in props, it does itterate but is not outputted into HTML.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…