component: apply PropType plugin to props
This commit is contained in:
parent
78bf7bd632
commit
ffeb447dc1
@ -1,39 +1,46 @@
|
|||||||
import React from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import classes from './burgerIngredient.css';
|
import classes from './burgerIngredient.css';
|
||||||
|
|
||||||
const burgerIngredient = (props) => {
|
class BurgerIngredient extends Component {
|
||||||
let ingredient = null;
|
render() {
|
||||||
|
let ingredient = null;
|
||||||
|
|
||||||
switch (props.type) {
|
switch (this.props.type) {
|
||||||
case ('bread-bottom'):
|
case ('bread-bottom'):
|
||||||
ingredient = <div className={classes.BreadBottom}></div>
|
ingredient = <div className={classes.BreadBottom}></div>
|
||||||
break;
|
break;
|
||||||
case ('bread-top'):
|
case ('bread-top'):
|
||||||
ingredient = (
|
ingredient = (
|
||||||
<div className={classes.BreadTop}>
|
<div className={classes.BreadTop}>
|
||||||
<div className={classes.Seeds1}></div>
|
<div className={classes.Seeds1}></div>
|
||||||
<div className={classes.Seeds2}></div>
|
<div className={classes.Seeds2}></div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
break;
|
break;
|
||||||
case ('meat'):
|
case ('meat'):
|
||||||
ingredient = <div className={classes.Meat}></div>
|
ingredient = <div className={classes.Meat}></div>
|
||||||
break;
|
break;
|
||||||
case ('cheese'):
|
case ('cheese'):
|
||||||
ingredient = <div className={classes.Cheese}></div>
|
ingredient = <div className={classes.Cheese}></div>
|
||||||
break;
|
break;
|
||||||
case ('salad'):
|
case ('salad'):
|
||||||
ingredient = <div className={classes.Salad}></div>
|
ingredient = <div className={classes.Salad}></div>
|
||||||
break;
|
break;
|
||||||
case ('bacon'):
|
case ('bacon'):
|
||||||
ingredient = <div className={classes.Bacon}></div>
|
ingredient = <div className={classes.Bacon}></div>
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ingredient = null;
|
ingredient = null;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
return ingredient;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ingredient;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BurgerIngredient.PropTypes = {
|
||||||
|
type: PropTypes.string.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
export default burgerIngredient;
|
export default burgerIngredient;
|
Loading…
Reference in New Issue
Block a user