title: Right way to fetch data with react using socket.io
body: <p>I didn't found any examples about how to fetch data from express server using react with socket.io.</p>
  
  <p>Now i do something like this:
  Server.js</p>
  
  <pre><code>io.on('connection', socket =&gt; {
    console.log(socket.id)
  
    socket.on('disconnect', () =&gt; {
      console.log(socket.id + ' disconnected')
    })
  
    socket.on('load settings', () =&gt; {
      socket.emit('settings is here', data)
    })
  })
  </code></pre>
  
  <p>React.js</p>
  
  <pre><code>const [socket] = useState(io())
    const [settings, setSettings] = useState(false)
  
     useEffect(() =&gt; {
      try {
        socket.emit('load settings');
  
        socket.on('settings is here', (data) =&gt; {
          // we get settings data and can do something with it
          setSettings(data)
        })
      } catch (error) {
        console.log(error)
      }
    }, [])
  </code></pre>