This works:
const addGoalHandler = () => {
setCourseGoals(currentGoals => [...currentGoals, enteredGoal]);
};
But this way it works differently:
const addGoalHandler = () => {
let arrGoals = courseGoals;
arrGoals.push(enteredGoal);
setCourseGoals(arrGoals);
};
Both methods are supposed to add the content of the input into an array, and then this array should be rendered as a list. The first does, but the second only renders the list when the value of the input changes. Any idea why that happens?