I want to add data on a div that comes from socket. And remove it after 5 seconds. (I am using socket.io client)
socket.on("data", (data) => {
// add this data on div
setTimeout(()=>{
// remove data from div.
}, 5000);
})
But a setTimeout function added each time a message arrives. May this a performance issue after some times? Should I remove it?