tooot/src/utils/startup/netInfo.ts

16 lines
368 B
TypeScript
Raw Normal View History

2021-01-07 19:13:09 +01:00
import NetInfo from '@react-native-community/netinfo'
import { onlineManager } from '@tanstack/react-query'
2021-01-07 19:13:09 +01:00
import log from './log'
2023-01-16 22:11:41 +01:00
const netInfo = () => {
2021-01-07 19:13:09 +01:00
log('log', 'netInfo', 'initializing')
2021-03-15 22:30:29 +01:00
2022-01-16 23:26:05 +01:00
onlineManager.setEventListener(setOnline => {
return NetInfo.addEventListener(state => {
setOnline(!!state.isConnected)
2022-01-16 23:26:05 +01:00
})
})
2021-01-07 19:13:09 +01:00
}
export default netInfo