fix: websocket handlers

This commit is contained in:
canove
2020-08-10 19:24:15 -03:00
parent 1c0e251b24
commit c7c451d227
4 changed files with 16 additions and 9 deletions

View File

@@ -25,7 +25,7 @@ import TabPanel from "../TabPanel";
import api from "../../services/api";
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
let socket;
const useStyles = makeStyles(theme => ({
ticketsWrapper: {
@@ -209,12 +209,13 @@ const Tickets = () => {
}, [searchParam, pageNumber, token, tab]);
useEffect(() => {
socket = openSocket(process.env.REACT_APP_BACKEND_URL);
socket.emit("joinNotification");
return () => {
socket.disconnect();
};
}, [ticketId]);
}, []);
useEffect(() => {
socket.on("ticket", data => {