我知道要做出反應,似乎無法通過這段代碼。我有一些我想輸出到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>