The data needs to be stored somewhere. To do this, let’s use the @react-native-async-storage/async-storage
library.
Let’s write two functions to save and read data in the functions.js
file at the root of the project.
Let’s call these functions setStorage
for saving and readStorage
for reading.
setStorage
takes two arguments - the data key and the data itself.
The data in async-storage
must be stored as a JSON string under the passed key using the setItem
method.
readStorage
must read a method from async-storage
by the key passed to it using the getItem
method.
If there is no data, let’s return null
.
Remember - both methods must be asynchronous and wait for setItem
or getItem
to execute.
This task is part of the Full-Stack JavaScript Course.
If you have any issues with it, you can ask for community help below the post.
Feel free to help others if you’ve already solved the task.