React Native

App Lifecycle & Background Execution

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

20 mülakat soruları·
Mid-Level
1

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

Cevap

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?

Cevap

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?

Cevap

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 mülakat soruları

Bir sonraki mülakatın için React Native'de uzmanlaş

Tüm sorulara, flashcards'a, teknik testlere, code review alıştırmalarına ve mülakat simülatörlerine eriş.

Ücretsiz başla