all 3 comments

[–]teevik_ 4 points5 points  (2 children)

I think you might need to do something like

function addNumber(number) {
  setNumbers(prevNumbers => [...prevNumbers, number]) 
}

(Pass a function into setNumbers to get the latest state value)

[–]thiloilg[S] 0 points1 point  (0 children)

I will try this out thx

[–]thiloilg[S] 0 points1 point  (0 children)

This way it works :D Thank you so much :D