N
N
Nikolay220002020-08-18 22:32:34
Socket.io
Nikolay22000, 2020-08-18 22:32:34

React socket io How to send a message?

Good time of day there is a ready server on the socket
made import io from 'socket.io-client';
Created connection all is well
socket.on('message', function(msg) {
console.log(msg)
});
But I want to send a message
socket.emit('message', function(msg) {
console.log(msg)
});
But I have no idea how to send via input in html.

Send
Che, I can’t find how to add

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex4answ, 2020-08-18
@alex4answ

How to process a normal form, why do you need to write in html when submitting?
If you are using React then you just need to add this message to the "dialog" state and then react will add the new message to the html by itself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question