Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ojaynico/ojaynico-kotlin-react-native-async-storage

Repository files navigation

ojaynico-kotlin-react-native-async-storage

Maven Central Kotlin npm version Kotlin JS IR supported

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/

How to use the wrapper?

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")
}

Example of code snippet for a react native app using the above wrapper

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() {
 ...
 }
}

About

Kotlin Wrapper for React Native Async Storage

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

Languages

AltStyle によって変換されたページ (->オリジナル) /