0
0
React Nativemobile~20 mins

SecureStore for sensitive data in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SecureStore Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What happens when you try to retrieve a non-existent key from SecureStore?
Consider this React Native code snippet using SecureStore to get a value for a key that was never saved. What will be the output?
React Native
import * as SecureStore from 'expo-secure-store';

async function getValue() {
  const result = await SecureStore.getItemAsync('missingKey');
  console.log(result);
}

getValue();
AEmpty string ('')
Bundefined
CThrows an error
Dnull
Attempts:
2 left
💡 Hint
Think about what SecureStore returns when the key does not exist.
lifecycle
intermediate
2:00remaining
When should you clear sensitive data from SecureStore in a React Native app?
You store a user's authentication token in SecureStore. When is the best time to remove this token to keep the app secure?
AWhen the app goes to background
BWhen the app is closed by the user
CWhen the user logs out
DNever remove it to keep user logged in
Attempts:
2 left
💡 Hint
Think about user control and security best practices.
📝 Syntax
advanced
2:00remaining
Which code snippet correctly saves and retrieves a password securely using SecureStore?
Choose the option that correctly saves a password and then retrieves it asynchronously using SecureStore in React Native.
A
await SecureStore.setItemAsync('password', 'myPass123');
const pass = await SecureStore.getItemAsync('password');
console.log(pass);
B
SecureStore.setItem('password', 'myPass123');
const pass = SecureStore.getItem('password');
console.log(pass);
C
await SecureStore.save('password', 'myPass123');
const pass = await SecureStore.load('password');
console.log(pass);
D
SecureStore.setItemAsync('password', 'myPass123');
const pass = SecureStore.getItemAsync('password');
console.log(pass);
Attempts:
2 left
💡 Hint
Remember the exact method names and that these are async functions.
🔧 Debug
advanced
2:00remaining
Why does this SecureStore code fail to save data?
Identify the reason this code does not save the data as expected.
React Native
import * as SecureStore from 'expo-secure-store';

function saveData() {
  SecureStore.setItemAsync('token', 'abc123');
}
saveData();
AWrong method name, should be saveItemAsync
BMissing await before SecureStore.setItemAsync call
CSecureStore requires a callback, not a promise
DKey 'token' is reserved and cannot be used
Attempts:
2 left
💡 Hint
Check how async functions should be handled.
🧠 Conceptual
expert
2:00remaining
What is the main security advantage of using SecureStore over AsyncStorage for sensitive data?
Choose the best explanation for why SecureStore is preferred for storing sensitive information like passwords or tokens.
ASecureStore encrypts data and stores it in the device's secure hardware-backed storage, while AsyncStorage stores data unencrypted in plain text.
BSecureStore automatically backs up data to the cloud, AsyncStorage does not.
CSecureStore is faster than AsyncStorage for large data sets.
DSecureStore allows data sharing between apps, AsyncStorage does not.
Attempts:
2 left
💡 Hint
Think about data protection and encryption.