我想 setInterval 连接检查,但它不适合我。有人可以向我解释为什么以及我该怎么做吗?谢谢!
import React, { Component } from 'react';
import { StyleSheet, TouchableWithoutFeedback, Keyboard, Text, View, TouchableOpacity, Image, Alert, TextInput, FlatList, Button, RefreshControl } from 'react-native';
import NetInfo from "@react-native-community/netinfo";
import * as signalR from '@aspnet/signalr';
const hubUrl = '/chatHub';
const hub = new signalR.HubConnectionBuilder()
.withUrl(hubUrl)
.configureLogging(signalR.LogLevel.Information)
.build();
setInterval(NetInfo.getConnectionInfo().then((connectionInfo) => {
alert(
'Initial, type: ' +
connectionInfo.type +
', effectiveType: ' +
connectionInfo.effectiveType,
);
}),1000);
export default class ChatScreen extends Component { }