asyncstorage-down
asyncstorage-down copied to clipboard
Switch to @react-native-community/async-storage
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 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 })
})
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": {