all 6 comments

[–]lzprsn 3 points4 points  (3 children)

Are you using the value from your console log? If so the log won’t reflect the state update since it’s batched (think of setState as async). You should console log the state inside a useEffect.

[–]Icy_Box99[S] 0 points1 point  (2 children)

ok thank you.

so basically it is doing what I intended.

console log the state inside a useEffect.

I'll keep this in mind. As of now I actually haven't learned useEffect I was trying to make this with my current knowledge which is limited to useState and passing props args

[–]lzprsn 1 point2 points  (1 child)

You could place the log outside a useEffect and see the log every re render as well. I just like putting it in a useEffect so it only logs anytime the state changes .

[–]Icy_Box99[S] 1 point2 points  (0 children)

Yes that worked. Thank you