network.NetworkState
The device's network as the app can use it now: its kind, whether it is connected, and whether the internet answers.
Utilização
Display an offline hint
Este tipo é usado por network.state
import { Text, network } from 'kuito';
network.state.value; // the state now, synchronously
await network.refresh(); // the same, read off the JS thread
function OfflineBanner() {
return <Text>{network.state.value.isInternetReachable ? '' : 'You are offline'}</Text>;
}Declaração do tipo
export type NetworkState = State;Membros 4
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
type | NetworkStateType | Sim | — |
isConnected | boolean | Sim | A network is up. It may still lack internet access, as behind a captive portal. |
isInternetReachable | boolean | Sim | The platform judges the network usable for the internet (docs/network.md). |
details | NetworkDetails | Sim | — |
details — campos aninhados
details campos
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
isExpensive | boolean | Sim | Traffic may cost the user: cellular, a hotspot, or a network marked metered. |
cellularGeneration | CellularGeneration | Sim | The radio's generation on cellular; null elsewhere or when the platform won't say. |
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.