Thanks in advance. I have a state array as below.
I need to add an item to state array, I came across that we need not do state mutation. How do i set state with prevSta
There is no real need to use the prevState, you could just do:
setMessages([...messages, newMessage])