pouchdb-react-native icon indicating copy to clipboard operation
pouchdb-react-native copied to clipboard

Error: Invalid Adapter: asyncstorage

Open adaboubvincent opened this issue 2 years ago • 2 comments

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 at node_modules@react-native\js-polyfills\error-guard.js:null in ErrorUtils.applyWithGuard at node_modules\metro-runtime\src\polyfills\require.js:null in guardedLoadModule at http://192.168.1.137:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:null in metroRequire at http://192.168.1.137:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:null in global

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', });

adaboubvincent avatar Aug 25 '23 11:08 adaboubvincent

same issue please solution

RaghavGurjar avatar Oct 12 '23 05:10 RaghavGurjar

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

VigneshmoorthyK avatar Mar 28 '24 08:03 VigneshmoorthyK