import { useCallback , useEffect , useState } from 'react' ; import { getInstallationTimeAsync } from 'expo-application' ; see https example export function useApplicationInstallTime ( options = { } ) { const [ applicationInstallTime , setApplicationInstallTime ] = useState < Date > ( ) ; const { get = true } = options ; const getApplicationInstallTime = useCallback ( ( ) => ( getInstallationTimeAsync ( ) . then ( setApplicationInstallTime ) ) , [ ] ) ; useEffect ( ( ) => { if ( get ) { getApplicationInstallTime ( ) ; } } , [ get , getApplicationInstallTime ] ) ; return [ applicationInstallTime , getApplicationInstallTime ] ; } export interface ApplicationInstallTimeOptions { /** If it should fetch the application install time when mounted, defaults to `true` */ get ? : boolean ; }