import React from 'react'; import { View, Text, Pressable } from 'react-native'; import * as Updates from '../'; const { checkForUpdateAsync, fetchUpdateAsync, useUpdates } = Updates; const UseUpdatesTestApp = () => { const { currentlyRunning, availableUpdate, downloadedUpdate, isUpdateAvailable, isUpdatePending, checkError, downloadError, initializationError, lastCheckForUpdateTimeSinceRestart, } = useUpdates(); return ( {/* Currently running info */} {currentlyRunning.updateId} {currentlyRunning.channel} {currentlyRunning?.createdAt ? currentlyRunning?.createdAt.toISOString() : ''} {/* Last time there was a check for update */} {lastCheckForUpdateTimeSinceRestart?.toISOString().substring(0, 19) || ''} {/* Available update, if one is present */} {availableUpdate?.updateId || ''} {/* Downloaded update, if one is present */} {downloadedUpdate?.updateId || ''} {/* Booleans */} {`${isUpdateAvailable}`} {`${isUpdatePending}`} {`${ availableUpdate?.type === Updates.UpdateInfoType.ROLLBACK }`} {`${ availableUpdate?.createdAt.toISOString().substring(0, 19) || '' }`} {/* Errors, if they occur */} {checkError ? {checkError.message} : null} {downloadError ? {downloadError.message} : null} {initializationError ? ( {initializationError.message} ) : null} {/* Buttons for test code to invoke methods */} checkForUpdateAsync()} /> fetchUpdateAsync()} /> ); }; export default UseUpdatesTestApp;