Spaces:
Paused
Paused
File size: 452 Bytes
a0fda44 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import { useSelector } from "react-redux";
import { io } from "socket.io-client";
const socket = io();
const useSocket = () => {
const userId = useSelector((state) => state.userReducer.user._id);
const socketEmit = (action, payload, fn) => {
socket.emit(action, payload, fn);
};
const socketListen = (action, fn) => {
socket.on(action, fn);
};
return { socketEmit, socketListen, userId, socket };
};
export default useSocket;
|