Answer the question
In order to leave comments, you need to log in
What can replace FileReader in react?
I am rewriting js code in react native. Everything works for me, only there is no file reader in react. It shows that everything is connected, but throws an error after onmessage...
reader = new FileReader();
reader.onload = function() {
alert(reader.result);
}
var socket = new WebSocket("ws://77.87.917.23:8023", 'binary');
socket.onopen = function() {
alert("Соединение установлено.");
};
socket.onclose = function(event) {
if (event.wasClean) {
alert('Соединение закрыто чисто');
} else {
alert('Обрыв соединения'); // например, "убит" процесс сервера
}
alert('Код: ' + event.code + ' причина: ' + event.reason);
};
socket.onmessage = function(event) {
reader.readAsText(event.data);
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question