https://dev.to/bravemaster619/how-to-use-socket-io-client-correctly-in-react-app-o65

1. Create Socket Context

We will use useContext hook to provide SocketContext to entire app.

Create a file in context/socket.js:

import socketio from "socket.io-client";
import { SOCKET_URL } from "config";

export const socket = socketio.connect(SOCKET_URL);
export const SocketContext = React.createContext();

0 commenti

Lascia un commento

Segnaposto per l'avatar