Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to @react-native-community/async-storage #10

Open
alebedev opened this issue Sep 2, 2019 · 2 comments · May be fixed by #13
Open

Switch to @react-native-community/async-storage #10

alebedev opened this issue Sep 2, 2019 · 2 comments · May be fixed by #13

Comments

@alebedev
Copy link

alebedev commented Sep 2, 2019

Using AsyncStorage in react-native 0.60 gives a warning that it will be removed in next version. We should switch to @react-native-community/async-storage to fix this

@mvayngrib
Copy link
Member

@alebedev you can pass in @react-native-community/async-storage yourself and you won't have a warning (i think):

import asyncstorageDown from 'asyncstorage-down'
import levelup from 'levelup'
import AsyncStorage from '@react-native-community/async-storage'

const db = levelup('/does/not/matter', {
  // the magic line:
  db: location => asyncstorageDown(location, { AsyncStorage })
})

@jakubukrop
Copy link

We use asyncstorage-down indirectly via another library and cannot pass parameters to it.
A simple patch can solve this.

diff --git a/node_modules/asyncstorage-down/default-opts.js b/node_modules/asyncstorage-down/default-opts.js
index c076d3d..88708e5 100644
--- a/node_modules/asyncstorage-down/default-opts.js
+++ b/node_modules/asyncstorage-down/default-opts.js
@@ -1,5 +1,5 @@
 module.exports = {
   get AsyncStorage() {
-    return require('react-native').AsyncStorage
+    return require('@react-native-community/async-storage').default
   }
 }
diff --git a/node_modules/asyncstorage-down/package.json b/node_modules/asyncstorage-down/package.json
index 6b6cdd2..9285195 100644
--- a/node_modules/asyncstorage-down/package.json
+++ b/node_modules/asyncstorage-down/package.json
@@ -25,7 +25,7 @@
     "eslint": "^5.9.0",
     "husky": "^1.1.3",
     "levelup": "^1.3.0",
-    "react-native": "file:./mock-react-native",
+    "@react-native-community/async-storage": "file:./mock-react-native",
     "tape": "^4.6.3"
   },
   "repository": {

@tudorgergely tudorgergely linked a pull request Aug 27, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants