React socket.emit() not working when app is refreshed ?
hey guys so im currently using socket.io for a real time chat app and my issue is that i have a useEffect which runs only on component mount okay and that fires
socket.connect()
and then socket.emit
s an event but for some reason when i refresh the app the component mounts right? and that should fire the emit event right? but it doesnt? its not received in the backend for some reason
ive added console.logs to ensure my useEffect
runs and it does but in the backend i dont get any logs from the event it should catch 😦
now it does work when i visit another component and get back to the component that has the socket event but for some reason it doesn't work on app refresh in the browser
id like some help ill paste the code below
im getting this console.log("A user connected:", socket.id);
on the terminal but not console.log(Received login event for userId: ${userId});
when i refresh 😦0 Replies