Skip to main content

8.19 Displaying And Updating Burger Price

BurgerBuilder.js

BurgerBuilder.js
...

return (
<Fragment>
<Burger ingredients={this.state.ingredients} />
<BuildControls
ingredientAdded={this.addIngredientHandler}
ingredientRemoved={this.removeIngredientHandler}
disabled={disabledInfo}
price={this.state.totalPrice}
/>
</Fragment>
);
}
}
export default BurgerBuilder;

BuildControls.js

BuildControls.js
...

const buildControls = (props) => (
<div className={classes.BuildControls}>
<p>
Current Price: <strong>{props.price.toFixed(2)}</strong>
</p>
{controls.map((ctrl) => (
<BuildControl
key={ctrl.label}
label={ctrl.label}
added={() => props.ingredientAdded(ctrl.type)}
removed={() => props.ingredientRemoved(ctrl.type)}
disabled={props.disabled[ctrl.type]}
/>
))}
</div>
);

export default buildControls;