React - JSX syntax issue, and how to iterate with map and display items on newlines

前端 未结 2 392
清酒与你
清酒与你 2021-01-27 09:27

I\'m a React noob and making a ToDo list style Recipe List app. I have a functional component, Item.js, and I am using JSX and the map function to iterate through each recipe it

2条回答
  •  被撕碎了的回忆
    2021-01-27 10:26

    If you add curly braces after the fat arrow, you will have to explicitly return the JSX.

    const Item = (props) => (
      
    {props.items.map((item, index) => { return (

    {item}

    {props.ingredients[index].map((ingredient, ingredientIndex) => { return (

    {ingredient}
    ) }}

    ) } )}
    )

提交回复
热议问题