我知道要做出反应,似乎无法通过这段代码。我有一些我想输出到dom的数据,但我不确定如何去做。谁能帮忙?在反应中输出对象数组的正确方法是什么?
的样本数据: App.js:
constructor(props){
super(props);
this.state.foods = [
{
recipe: '1 cup egg, 4 cups...',
time: 42
},
{
recipe: '1 tbsp butter, 2 cups...',
time: 120
}
]
}
`render(){
<div className='App'>
<Recipes data={this.state.foods} />
</div>
`
我将如何正确去在我的食谱分量输出呢?我已经尝试过对this.props.foods数组的内容进行forEach循环,但无法使其工作,任何帮助都会很棒。
The output I would like to see is:
<H2> 1 cup egg, 4 cups...</h2>
<h3> Time: 42 minutes </h2>
<br>
<H2> 1 tbsp butter, 2 cups...</h2>
<h3> Time: 120 minutes </h2>