title: Socket.io is not connecting with client (react.js)
body: <p>I am trying to connect my socket.io server with the client, but I am not getting any message that it is connected or not.
  I am using React.js for the front-end and node.js, express.js, and MongoDB for backend.</p>
  <p>I don't understand whether there is a fault in the server code or in the client.
  please help :&quot;)</p>
  <p>socketServer/index.js</p>
  <pre><code>const io = require(&quot;socket.io&quot;)(6000, {
    cors: {
      origin: &quot;http://localhost:3000&quot;,
    },
  });
  
  io.on(&quot;connection&quot;, (socket) =&gt; {
      console.log(&quot;user has been connected&quot;);
  })
  
  </code></pre>
  <p>socketServer/package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;socketServer&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;nodemon index.js&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;cors&quot;: &quot;^2.8.5&quot;,
      &quot;nodemon&quot;: &quot;^2.0.16&quot;,
      &quot;socket.io&quot;: &quot;^4.5.1&quot;
    }
  }
  
  </code></pre>
  <p>client/Messenger.jsx</p>
  <pre><code>import React, { useContext, useEffect, useRef, useState } from 'react'
  
  import { io } from &quot;socket.io-client&quot;;
  
  export default function Messenger() {
      const [socket, setSocket] = useState(null);
      useEffect(() =&gt; {
          setSocket(io(&quot;ws://localhost:6000&quot;));
          console.log(&quot;tadan tadan&quot;, socket);
      }, [])
   return (
          &lt;&gt;
            this is messenger
          &lt;/&gt;
      )
  }
  </code></pre>