Challenge - 5 Problems
MMKV Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What happens when you store and retrieve a value using MMKV?
Consider this React Native code using MMKV storage. What will be the output shown on the screen after pressing the button?
React Native
import React, { useState } from 'react'; import { View, Text, Button } from 'react-native'; import { MMKV } from 'react-native-mmkv'; const storage = new MMKV(); export default function App() { const [value, setValue] = useState(''); const saveAndLoad = () => { storage.set('greeting', 'Hello MMKV'); const stored = storage.getString('greeting'); setValue(stored ?? ''); }; return ( <View> <Button title="Save & Load" onPress={saveAndLoad} /> <Text>{value}</Text> </View> ); }
Attempts:
2 left
💡 Hint
MMKV stores data synchronously and getString returns the saved string immediately.
✗ Incorrect
MMKV's set and getString methods are synchronous. After saving 'Hello MMKV' with set, getString returns it immediately, so the text updates correctly.
❓ lifecycle
intermediate1:30remaining
When is MMKV storage data persisted in React Native?
In a React Native app using MMKV, when is the data saved by MMKV guaranteed to be persisted?
Attempts:
2 left
💡 Hint
Think about synchronous vs asynchronous storage methods.
✗ Incorrect
MMKV writes data synchronously to disk when you call set, so data is immediately persisted without waiting for app lifecycle events.
🔧 Debug
advanced2:00remaining
Why does this MMKV getString call return null unexpectedly?
Look at this code snippet:
const storage = new MMKV();
storage.set('key', 'value');
const val = storage.getString('Key');
Why does val return null?
Attempts:
2 left
💡 Hint
Check the spelling and casing of keys carefully.
✗ Incorrect
MMKV keys are case-sensitive. 'key' and 'Key' are different keys, so getString('Key') returns null if only 'key' was set.
🧠 Conceptual
advanced1:30remaining
What is a key advantage of MMKV over AsyncStorage in React Native?
Choose the main advantage MMKV provides compared to AsyncStorage for React Native apps.
Attempts:
2 left
💡 Hint
Think about performance and how data is accessed.
✗ Incorrect
MMKV uses mmap and native code for very fast synchronous storage, making it faster and more efficient than AsyncStorage which is async and slower.
📝 Syntax
expert2:30remaining
Which MMKV usage snippet correctly stores and retrieves a boolean value?
Select the code snippet that correctly saves a boolean and retrieves it using MMKV in React Native.
Attempts:
2 left
💡 Hint
Check the MMKV API method names carefully.
✗ Incorrect
The MMKV API uses set(key, value) for all types and getBoolean(key) to retrieve booleans. Option D uses correct method names and types.