component: display BuildControls by iterating the Control objects array

This commit is contained in:
oscarzhou 2020-12-10 19:38:38 +13:00
parent 8435d19d87
commit 24db148125
7 changed files with 23 additions and 16 deletions

1
.gitignore vendored
View File

@ -19,3 +19,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
debug.log

View File

@ -1,15 +0,0 @@
import React from 'react'
import BuildControl from './BuildControl/BuildControl';
import classes from './BuildControls.css';
const buildControls = (props) => (
<div className={classes.buildControls}>
<BuildControl Name="Meat" />
<BuildControl Name="Cheese" />
<BuildControl Name="Salad" />
<BuildControl Name="Bacon" />
</div>
)
export default buildControls;

View File

@ -0,0 +1,21 @@
import React from 'react'
import BuildControl from './BuildControl/BuildControl';
import classes from './BuildControls.css';
const controls = [
{ name: 'Salad', type: 'salad'},
{ name: 'Cheese', type: 'cheese'},
{ name: 'Bacon', type: 'bacon'},
{ name: 'Meat', type: 'meat'},
];
const buildControls = (props) => (
<div className={classes.BuildControls}>
{controls.map( ctrl => (
<BuildControl Key={ctrl.name} Name={ctrl.name} />
))}
</div>
)
export default buildControls;

View File

@ -2,7 +2,7 @@ import React, { Component } from 'react';
import Aux from '../../hoc/Auxiliary';
import Burger from '../../components/Burger/Burger';
import BuildControls from '../../components/BuildControls/BuildControls';
import BuildControls from '../../components/Burger/BuildControls/BuildControls';
class BurgerBuilder extends Component {