robwalkerco / redux-persist-filesystem-storage

Redux persist adaptor for React Native filesystem storage
MIT License
196 stars 71 forks source link

typeError: Cannot read properties of undefined (reading 'DocumentDir') on Android #58

Closed Metourni closed 1 year ago

Metourni commented 2 years ago

I am getting this error after installing the library.

typeError: Cannot read properties of undefined (reading 'DocumentDir')

package.json

"dependencies": { "@react-native-async-storage/async-storage": "^1.15.13", "@react-native-community/datetimepicker": "^3.5.2", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^7.1.2", "@react-navigation/bottom-tabs": "^5.10.2", "@react-navigation/native": "^5.8.2", "@react-navigation/stack": "^5.11.1", "axios": "^0.24.0", "http-status-codes": "^2.1.4", "lodash": "^4.17.20", "moment": "^2.29.1", "prop-types": "^15.7.2", "react": "17.0.2", "react-native": "0.64.2", "react-native-camera": "^4.2.1", "react-native-dots-pagination": "^0.2.0", "react-native-gesture-handler": "1.10.3", "react-native-gifted-chat": "^0.16.3", "react-native-linear-gradient": "^2.5.6", "react-native-modal-datetime-picker": "^13.0.0", "react-native-onesignal": "^4.3.3", "react-native-permissions": "^3.1.0", "react-native-qrcode-scanner": "^1.5.4", "react-native-qrcode-svg": "^6.1.1", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-reanimated": "^2.2.0", "react-native-safe-area-context": "^3.1.8", "react-native-screens": "^3.4.0", "react-native-size-matters": "^0.4.0", "react-native-smooth-pincode-input": "^1.0.9", "react-native-splash-screen": "^3.2.0", "react-native-svg": "^12.1.0", "react-native-swiper": "^1.6.0", "react-native-toast-message": "^2.0.1", "react-native-vector-icons": "^8.1.0", "react-redux": "^7.2.6", "redux": "^4.1.2", "redux-logger": "^3.0.6", "redux-persist": "^6.0.0", "redux-persist-filesystem-storage": "^4.0.0", "redux-saga": "^1.1.3", "reselect": "^4.1.5" },

store.js ` import FilesystemStorage from 'redux-persist-filesystem-storage'

const persistConfig = { key: 'root', storage: FilesystemStorage, } `

Android version: 11

scrapecoder commented 2 years ago

@Metourni did you find any solution? facing same issue

Metourni commented 2 years ago

@scrapecoder I did change the storage library:

Package.json:

` "dependencies": { ...

"@bankify/redux-persist-realm": "^0.1.3", "redux-persist": "^6.0.0", "realm": "^10.11.0",

... `

` import { createStore, applyMiddleware } from 'redux'; import { createLogger } from 'redux-logger'; import createSagaMiddleware from 'redux-saga'; import { persistStore, persistReducer } from 'redux-persist'; import { createRealmPersistStorage } from '@bankify/redux-persist-realm';

import rootReducer from './reducers'; import rootSaga from './sagas';

// config the persist const persistConfig = { key: '@key', storage: createRealmPersistStorage(), whitelist: ['profile', ...], }; // Persist the reducers const persistedReducer = persistReducer(persistConfig, rootReducer);

// Middleware: Redux Saga const sagaMiddleware = createSagaMiddleware();

// Redux: Store export const store = createStore( // mount it on the Store persistedReducer, applyMiddleware( sagaMiddleware, createLogger(), ), );

// Persist store export const persistor = persistStore(store);

// Middleware: Redux Saga sagaMiddleware.run(rootSaga);

export default { store, persistor };

`

and also I had to close the emulator, clear the build and reinstall all the packages.

amingsc commented 2 years ago

meet the same error. version 4.1.0 my fix: 1.remove redux-persist-filesystem-storage 2.manual add dependency: react-native-blob-util 3.add redux-persist-filesystem-storage again

zabojad commented 1 year ago

I'l facing the same issue on RN 0.71 with new architecture but @amingsc 's solution doesn't seem to help...

zabojad commented 1 year ago

Fixed by PR https://github.com/robwalkerco/redux-persist-filesystem-storage/pull/65

robwalkerco commented 1 year ago

Thanks @zabojad for the PR

It's been merged and published as version 4.2.0