pouchdb-react-native
pouchdb-react-native copied to clipboard
Error: Invalid Adapter: asyncstorage
I updated my expo version from 47 to 49 and I get this error after execution.
Error: Invalid Adapter: asyncstorage, js engine: hermes
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:null in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:null in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:null in handleError
at node_modules\expo\build\errors\ExpoErrorManager.js:null in createErrorHandler
at node_modules\expo\build\errors\ExpoErrorManager.js:null in
The code :
import React, { useContext } from 'react'; import PouchDB from 'pouchdb-react-native'; import PouchAuth from 'pouchdb-authentication'; import PouchAsyncStorage from 'pouchdb-adapter-asyncstorage'; import { storeData } from './storageManager';
PouchDB.plugin(PouchAuth); PouchDB.plugin(require('pouchdb-upsert')); PouchDB.plugin(require('pouchdb-find'));
PouchDB.plugin(PouchAsyncStorage);
let LocalDatabase = new PouchDB('db_name', { adapter: 'asyncstorage', });
same issue please solution
Yeah it seems to be the asyncstorage has been removed from react-native latest versions.
AsyncStoragePouch.valid = () => { try { return require('@react-native-async-storage/async-storage').default !== null } catch (error) { return false } }
quick fix change the asyncstorage from react-native to @react-native-async-storage/async-storage
node_modules/pouchdb-adapter-asyncstorage/src/index.js then run npx patch-package pouchdb-adapter-asyncstorage