React Native

App Lifecycle & Background Execution

AppState, foreground/background transitions, headless JS, background fetch, deep links, universal links

20 domande da colloquio·
Mid-Level
1

What are the three possible states returned by AppState.currentState in React Native?

Risposta

AppState.currentState returns one of three states: 'active' (app is in the foreground and interactive), 'background' (app is in the background but potentially running) and 'inactive' (transitional state on iOS, for example when displaying the multitasking view). On Android, 'inactive' state is rare as the transition goes directly between 'active' and 'background'.

2

Which method should be used to listen for application state changes with AppState?

Risposta

The AppState.addEventListener('change', callback) method allows listening for application state changes. The callback receives the new state ('active', 'background' or 'inactive') as a parameter. It is important to remove the listener using the remove() method returned by addEventListener during cleanup to avoid memory leaks.

3

When does the 'inactive' state typically occur on iOS?

Risposta

The 'inactive' state on iOS occurs during brief transitions: displaying the control center, notification center, multitasking screen (double tap Home), or during an incoming call. It is an intermediate state where the app is visible but not interactive. On Android, this state is rarely observed as the transition between 'active' and 'background' is direct.

4

How to correctly implement an AppState listener in a useEffect?

5

What is a Headless JS Task in React Native?

+17 domande da colloquio

Padroneggia React Native per il tuo prossimo colloquio

Accedi a tutte le domande, flashcards, test tecnici, esercizi di code review e simulatori di colloquio.

Inizia gratis