Stack Exchange
My Socket.io connection is connecting twice
I am making a connection between server(express, socket.io) and client(react).The connection is made but it is connecting two times.
client/src/App.js
import React from 'react';
import { io } from 'socket.io-client';

const App = () => {
  const socket = io('http://localhost:4000');
  socket.on("hello", (arg) => {
    console.log(arg);
  });

  return (
    <div>App</div>
  );
};

export default App;

server/server.js
const express = require("express");
const { createServer } = require("http");
const { Server } = require("socket.io");

const app = express();
const httpServer = createServer(app);
const io = new Server(httpServer, {
    cors:{
        origin: 'http://localhost:3000',
        methods: ['GET', 'POST']
    }
});

httpServer.listen(4000);

io.on("connection", (socket) => {
  console.log("a new user connected");
  socket.emit("hello", {
    id: 123,
    name: "John Doe",
    address: "Asia"
  })
});

How can I fixed it.
Browser console

I have tried to find from documentation but didn't. So, looking for your solution....
