Closed nik1999777 closed 2 years ago
To visualize the problem
The lastmessage state removes the component and replaces it with another one, and I want them to alternate one after another. What to do?
It does what you programmed it to do. You are overwriting the state variable with the new value, If you want to show all received messages save an array in the state, and add to it each message you receive. If you want to alternate between them on a time basis you have to program it that way, too.
This is not an issue with the react-stomp-hooks library. Please post general react question in the future to places like Stackoverflow. You can find other more appropriate places here: https://reactjs.org/community/support.html