Check out example codes for "socket io script". It will help you in understanding the concepts better.
Code Example 1
const socket = new WebSocket('ws://localhost:3000');socket.onopen(() => { socket.send('Hello!');});socket.onmessage(data => { console.log(data);});
Code Example 2
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
</script>
Learn ReactJs, React Native from akashmittal.com