I'm really close to achieving the final goal. My goal is to add X and the name of X is the input's value. I just want a little help that why the function isn't working(I'm sure the method is true). I would appreciate it if you explain it so I can find it myself.
Function:
const [activityNames, setName] = useState([
{ id: 1, name: 'Feel free to add, edit and delete!' }
]);
const handleSetName = e => {
const name = {
id: Math.random() * 10000,
name: e.target.value
};
let names = activityNames.concat(name)
setName(names);
};
Input:
<input type="text" placeholder="Aktivitätsname" value={activityNames.name} />
<button onClick={handleSetName}>
<i className="fas fa-plus"></i>
</button>