Client-side web pages / Single Page Apps (SPA)

Client-side “Quick Start”

React

JSX Details

Same thing from a different perspective:

Ingredient

IngredientList

You could do this:

function IngredientListDemo(props) {
   return React.createElement("ul", null, 
        IngredientList(props.ingredients[0]),
        IngredientList(props.ingredients[1]),
        IngredientList(props.ingredients[2]),
        ...
    )
}

But, it would be more common to use JSX

function IngredientListDemo(props) {
    let list = props.ingredients;
    return <ul className="ingredients" >
        <Ingredient amount={list[0].amount} measurement={list[0].measurement} name={list[0].name} key='0' />
        <Ingredient amount={list[1].amount} measurement={list[1].measurement} name={list[1].name} key='1' />
        <Ingredient amount={list[2].amount} measurement={list[2].measurement} name={list[2].name} key='2' />
        <Ingredient amount={list[3].amount} measurement={list[3].measurement} name={list[3].name} key='3' />
    </ul>;
}

But, rather than list each ingredient by hand, use a loop:

function IngredientList(props) {
    return <ul className="ingredients" > {
        props.ingredients.map((item, index) => (
            <Ingredient amount={item.amount} measurement={item.measurement} name={item.name} key={index} />
        ))}
    </ul>
}

Move the call to map before return so it is clearer what’s going on:

let ingredientList = props.ingredients.map((item, index) => (
            <Ingredient amount={item.amount} measurement={item.measurement} name={item.name} key={index} />
        ))}

Another shortcut:

State

function Menu({ title, recipes }) {
     int currentIndex = recipes.length /2;
    const recipe = recipes[currentIndex];

Bootstrap and React

Conventional React Deploy