Browse Source

Logging message error when the WebScoket face some problem

master
GabrielTrettel 3 years ago
parent
commit
99b6fdc107
  1. 5
      src/app/hooks/useSocketMarkers.js

5
src/app/hooks/useSocketMarkers.js

@ -153,9 +153,14 @@ function verifyResponse(response, name) {
function getFormsAnswers(socketObject, dispatch) { function getFormsAnswers(socketObject, dispatch) {
const [socketResponse, setSocketResponse] = useState(); const [socketResponse, setSocketResponse] = useState();
socketObject.socketUrl.onerror = (e) => {
console.log(e.message);
};
socketObject.socketUrl.onmessage = ({ data }) => { socketObject.socketUrl.onmessage = ({ data }) => {
setSocketResponse(data); setSocketResponse(data);
}; };
useEffect(() => { useEffect(() => {
dispatch({ increment: verifyResponse(socketResponse, socketObject.name) }); dispatch({ increment: verifyResponse(socketResponse, socketObject.name) });
}, [socketResponse]); }, [socketResponse]);

Loading…
Cancel
Save