React update arrays in list

PHOTO EMBED

Tue Sep 20 2022 08:37:08 GMT+0000 (UTC)

Saved by @Ddev #javascript #react.js

const addNewGoalHandler = (newGoal) => {
    // if the update of the states doesnt depend from the previous one
    setTask(task.concat(newGoal));
  	//also works setTodos([...todos, newTodo]);
    // setTask((prevtask) => {
    //   // if your state depends from the previous one
    //   return prevtask.concat(newGoal);
    // });
  };
content_copyCOPY

una forma de agregar elementos en un array luego de user input