React Native · APIs and utilities
Network
Network state.
4 exports
Import
Network
moduleNetwork state.
| Name | Type | Description |
|---|---|---|
getState | () => Promise<NetworkState> | The current state. |
addListener | (listener: (state: NetworkState) => void) => () => void | Called when the state changes. Returns a function that ends the subscription. |
useNetworkState
functionWatches the network state (null until the first value arrives).
NetworkType
typeConnection type.
NetworkState
interfaceNetwork state.
| Name | Type | Description |
|---|---|---|
connected | boolean | Whether it is connected to a network. |
internetReachable | boolean | Whether the internet is reachable. Android validates the network (false on Wi-Fi with a captive portal); iOS does not, it is the same as connected. |
type | NetworkType | Connection type. |
expensive | boolean | A metered connection (cellular data, hotspot). Defer large downloads. |
constrained | boolean | Data saver is on (iOS Low Data Mode, Android Data Saver). |