Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import MMKV storage in React Native.
React Native
import { [1] } from 'react-native-mmkv';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using AsyncStorage instead of MMKV
Importing a wrong name like Storage or useMMKV
✗ Incorrect
You import MMKV from the react-native-mmkv package to use fast storage.
2fill in blank
mediumComplete the code to create a new MMKV storage instance.
React Native
const storage = new [1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to instantiate AsyncStorage which is not a class
Using wrong class names like Storage or StorageManager
✗ Incorrect
You create a new instance by calling new MMKV().
3fill in blank
hardFix the error in the code to save a string value with MMKV.
React Native
storage.[1]('username', 'Alice');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using save or put which are not MMKV methods
Trying to use AsyncStorage methods
✗ Incorrect
The correct method to save a string is setString.
4fill in blank
hardFill both blanks to read a string value and provide a default if missing.
React Native
const name = storage.[1]('username') || [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using setString instead of getString to read
Using null instead of a default string
✗ Incorrect
Use getString to read the value and provide a default like 'Guest' if it is missing.
5fill in blank
hardFill all three blanks to remove a stored key and check if it exists.
React Native
storage.[1]('username'); const exists = storage.[2]('username'); console.log(exists === [3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove which is not a method
Checking existence with wrong method
Comparing existence to true instead of false
✗ Incorrect
Use delete to delete a key, contains to check if it exists, and compare to false after removal.