0
0
React Nativemobile~20 mins

Why API integration connects to backends in React Native - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
API Integration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why do mobile apps use API integration to connect to backends?

Choose the best reason why mobile apps connect to backend servers using APIs.

ATo fetch and send data securely between the app and server
BTo make the app run faster without internet
CTo store all app data only on the device
DTo avoid using any server resources
Attempts:
2 left
💡 Hint

Think about how apps get updated information or save user data.

ui_behavior
intermediate
2:00remaining
What happens in the app UI when API data is loading?

When a React Native app calls an API to get data, what should the UI show while waiting for the response?

AShow blank screen with no feedback
BCrash the app to restart
CShow a loading spinner or message
DImmediately show old data without update
Attempts:
2 left
💡 Hint

Think about how apps keep users informed during slow network calls.

lifecycle
advanced
2:00remaining
When should a React Native app call backend APIs?

Which lifecycle event is best to trigger an API call to fetch data when a screen appears?

AInside the component constructor
BInside useEffect hook with empty dependency array
CInside a button click handler only
DInside the render method directly
Attempts:
2 left
💡 Hint

Think about when the component is ready and mounted.

navigation
advanced
2:00remaining
How to pass API data between screens in React Native?

You fetched user info from backend on Screen A. How do you pass this data to Screen B when navigating?

AUse console.log to share data
BStore data only in Screen A state without passing
CReload Screen B without any data
DPass data as parameters in navigation.navigate call
Attempts:
2 left
💡 Hint

Think about how navigation libraries pass info between screens.

🔧 Debug
expert
2:00remaining
Why does this React Native API call fail with 'Network request failed'?

Given this code snippet, why does the fetch fail?

fetch('http://localhost:3000/data')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error))
AMobile device cannot access localhost of development machine
Bresponse.json() is not a function
Cfetch requires POST method by default
DThe URL is missing https:// prefix
Attempts:
2 left
💡 Hint

Think about what 'localhost' means on a mobile device.