Answer the question
In order to leave comments, you need to log in
Why does a React Native app freeze?
I am writing the first application in react native, I created a websocket server, I receive data once a minute, everything seems to work fine, but then the application freezes and I can’t return to the main page
. Here is the server code:
io.on("connection", socket => {
console.log(`Connected: ${socket.id}`);
socket.on('disconnect', () => console.log(`Disconnected: ${socket.id}`));
async function requestMain(){
var result = await mainFunction();
await socket.emit("info", result);
setTimeout(requestMain, 60000);
};
requestMain();
});
server.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
var socket;
const [isLoading, setLoading] = useState(true);
const [data, setData] = useState([]);
useEffect(() => {
socket = io("http://example/", {
transports: ['websocket']
});
socket.on("info", info => {
setData(info);
setLoading(false);
});
return () => {
socket.disconnect();
};
}, [isLoading]);
//Далее идет парсинг JSON строки и строится DOM
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