Guest User

Untitled

a guest
Jan 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. // FONCTION
  2. handleIngredientNameChange = (idx) => (event) => {
  3. const newIngredient = this.state.ingredients.map((ingredient, sidx) => {
  4. if (idx !== sidx) return ingredient;
  5. return { ...ingredient, name: event.target.value };
  6. });
  7.  
  8. this.setState({ ingredients: newIngredient });
  9. }
  10.  
  11. // AJOUT DE CHAMPS
  12. handleAddIngredient = () => {
  13. this.setState({ ingredients: this.state.ingredients.concat([{ name: '' }]) });
  14. }
Add Comment
Please, Sign In to add comment