Skip to content

Instantly share code, notes, and snippets.

@emmabostian
Last active August 11, 2018 07:35
Show Gist options
  • Save emmabostian/c8dbf6e17683e0bbcd12c03348ddab1e to your computer and use it in GitHub Desktop.
Save emmabostian/c8dbf6e17683e0bbcd12c03348ddab1e to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class Recipe extends Component {
render() {
const ingredients = this.props.ingredients.map((ingredient, i) => <li key={i}>{ingredient}</li>);
const steps = this.props.steps.map((step, i) => <li key={i}>{step}</li>);
return (
<div className="Recipe">
<h2>{this.props.title}</h2>
<h3>Ingredients</h3>
<ul>
{ingredients}
</ul>
<h3>Steps</h3>
<ul>
{steps}
</ul>
</div>
);
}
}
Recipe.propTypes = {
ingredients: PropTypes.array.isRequired,
steps: PropTypes.array.isRequired,
title: PropTypes.string.isRequired
};
export default Recipe;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment