setState not working in react hooks when using map
Solution 1:
Try changing handleClick
to:
const handleClick = () => {
updatedUsers = users.map((user) => ({ firstName: user.nom, lastName: user.prenom }))
setNewUsersList([...newUsersList,...updatedUsers]);
};
Two notes: First, never change a state directly, but always use its setter. Second, it doesn't seems like you need newUser
state at all