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) {
const [socketResponse, setSocketResponse] = useState();
socketObject.socketUrl.onerror = (e) => {
console.log(e.message);
};
socketObject.socketUrl.onmessage = ({ data }) => {
setSocketResponse(data);
};
useEffect(() => {
dispatch({ increment: verifyResponse(socketResponse, socketObject.name) });
}, [socketResponse]);

Loading…
Cancel
Save