asyncstorage-down icon indicating copy to clipboard operation
asyncstorage-down copied to clipboard

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

Open alebedev opened this issue 5 years ago • 2 comments

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

alebedev avatar Sep 02 '19 12:09 alebedev

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

mvayngrib avatar Sep 02 '19 13:09 mvayngrib

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": {

jakubukrop avatar Sep 23 '19 07:09 jakubukrop