-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
31 lines (26 loc) · 927 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React, { useState } from "react";
import "./App.css";
import RecipeCreate from "./RecipeCreate";
import RecipeList from "./RecipeList";
import RecipeData from "./RecipeData"
function App() {
const [recipes, setRecipes] = useState(RecipeData);
const createRecipe = (newReceipe) => {
setRecipes([...recipes, newReceipe])
}
const deleteRecipe = (index) => {
const updatedRecipes = [...recipes];
updatedRecipes.splice(index, 1);
setRecipes(updatedRecipes);
};
// TODO: Add the ability for the <RecipeList /> component to list and delete an existing recipe.
// TODO: Add the ability for the <RecipeCreate /> component to create new recipes.
return (
<div className="App">
<header><h1>Delicious Food Recipes</h1></header>
<RecipeList recipes={recipes} deleteRecipe={deleteRecipe} />
<RecipeCreate createRecipe={createRecipe}/>
</div>
);
}
export default App;