score:0

You have to first connect to the socket server on the client side so for that add this

socket.on('connect', function(){});

before your event listener.

socket.on("FromAPI", data => this.setState({ response: data }));

Related Query

More Query from same tag