Skip to content

Instantly share code, notes, and snippets.

@t3h2mas
Created September 4, 2016 04:38
Show Gist options
  • Save t3h2mas/e280afd35b9c2ee64576fa9d56db2132 to your computer and use it in GitHub Desktop.
Save t3h2mas/e280afd35b9c2ee64576fa9d56db2132 to your computer and use it in GitHub Desktop.
Remove Recipe callback concern
import React from 'react';
import Recipe from './Recipe';
const RecipeBox = (props) => {
const removeRecipe = props.removeRecipe; // scope to `.map`
let recipeNodes = props.recipes.map((recipe) => {
return <Recipe
name={recipe.name}
ingredients={recipe.ingredients}
id={recipe.id}
key={recipe.id}
removeRecipe={removeRecipe}
/>
});
return (
<div className="recipe-box">
{recipeNodes}
</div>
)
};
RecipeBox.propTypes = {
recipes: React.PropTypes.array.isRequired
};
export default RecipeBox;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment