Kotlin wrapper for react-native-async-storage
Follow instructions in this repository on how to setup a fully working react native app
https://github.com/ojaynico/ojaynico-kotlin-react-native
After check out the following links on how to install async storage in react native.
https://react-native-async-storage.github.io/async-storage/docs/install/
Use the cli tool below to generate a new Kotlin React Native application.
https://github.com/ojaynico/create-ojaynico-krn
Proceed to the next step after generating the project.
Run the following command in your projects root directory.
npm install @react-native-async-storage/async-storage
In your react native application shared module (a kotlin gradle project), update your gradle file to include the following in the respective blocks.
repositories { mavenCentral() jcenter() } dependencies { implementation("com.github.ojaynico:ojaynico-kotlin-react-native-async-storage:1.1.1") }
class App : RComponent<RProps, RState>() { override fun componentDidMount() { GlobalScope.launch(Dispatchers.Main.immediate) { // Store a name using the setItem(key, value) function passing in two parameters AsyncStorage.setItem("name", "Nicodemus Ojwee").await() // Print out the name using the getItem(key) function with the above key "name" println(AsyncStorage.getItem("name").await()) } } override fun RBuilder.render() { ... } }