I'm trying to implement a simple history of message in React.
I want to use a useEffect Hook that will depend on the sentMessage state.
Upon trigger of the effect, I want to append to my history of messages the new value of the sent message.
However, using setHistoryState((prevValue) => prevValue.push(sentMessage) is, if I understand well, not the right way to proceed since historyState is not in the dependencies.
What is the correct way to implement this ?