import * as React from "react" ; import { useSelector } from "react-redux" ; import NetInfo , { NetInfoState } from "@react-native-community/netinfo" ; import moment from "moment" ; import "moment/locale/en-gb" ; import { StoreState , store } from "./store" ; import { setConnectionInfo } from "./store/actions" ; import { logger , setLogLevel } from "./logging" ; function handleConnectivityChange ( connectionInfo ) { logger . info ( `ConnectionfInfo: ${ connectionInfo . isConnected } ${ connectionInfo . type }` ) ; store . dispatch ( setConnectionInfo ( { type : connectionInfo . type , isConnected : connectionInfo . isConnected } ) ) ; } export default React . memo ( function SettingsGate ( props ) { const settings = useSelector ( ( state ) => state . settings ) ; React . useEffect ( ( ) => { setLogLevel ( settings . logLevel ) ; } , [ settings . logLevel ] ) ; React . useEffect ( ( ) => { moment . locale ( settings . locale ) ; } , [ settings . locale ] ) ; React . useEffect ( ( ) => { const unsubscribe = NetInfo . addEventListener ( handleConnectivityChange ) ; return unsubscribe ; } , [ ] ) ; return ( < > { props . children } < />); } ) ;