Coder Social home page Coder Social logo

nohac / redux-persist-expo-fs-storage Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 5.0 162 KB

Redux/Apollo Persist storage engine for React Expo file system

Home Page: https://www.npmjs.com/package/redux-persist-expo-fs-storage

License: MIT License

JavaScript 100.00%

redux-persist-expo-fs-storage's Introduction

Redux Persist FS Storage for Expo

Redux Persist storage engine for React Native Expo file system, this will also work for Apollo Persist.

Credits to techwes for porting this to the Expo FileSystem.

Install

yarn add redux-persist-expo-fs-storage

Usage

import { persistStore } from 'redux-persist'
import FSStorage from 'redux-persist-expo-fs-storage';

const persistor = persistStore(store, {storage: FSStorage()});

The default storage location is a folder called reduxPersist in the document directory for your app on the device. You can specify folder for persistor:

import { persistStore } from 'redux-persist'
import FSStorage, { CacheDir } from 'redux-persist-expo-fs-storage';

const cachePersistor = persistStore(store, {storage: FSStorage(CacheDir, 'myApp')});

This will create myApp folder in cache storage for iOS and Android devices. You may create multiple persistors on different directories.

redux-persist-expo-fs-storage's People

Contributors

dependabot[bot] avatar eleddie avatar gregthebusker avatar leethree avatar mlecoq avatar nohac avatar superyarik avatar techwes avatar wodcz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

redux-persist-expo-fs-storage's Issues

Issue with build android app

Hi thanks for your library.
When running my application inside expo persistence works fine.
However when I build the android bundle and execute it as a normal app my redux store always starts with an initial state.

Any ideas what could be wrong?

using

    "expo": "33.0.7",
    "expo-file-system": "5.0.1",
    "redux-persist-expo-fs-storage": "2.0.0",

and

export const persistedRootReducer = persistReducer(
  {
    key: "reduxstore",
    keyPrefix:"",
    stateReconciler: autoMergeLevel2,
    storage: FSStorage(),
  },
  rootReducer,
)

Deprecated import since expo 33

Hi,

I am using this module and I have the following warning caused by it :

- import { FileSystem } from 'expo' -> import * as FileSystem from 'expo-file-system'

Unable to resolve dependency tree when install with Expo 42

Steps to reproduce

expo init test --npm
cd test
expo install redux-persist-expo-fs-storage

Error

Installing 1 other package using npm.
> npm install --save redux-persist-expo-fs-storage
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/react-native
npm ERR!   react-native@"https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz" from the root project
npm ERR!   peer react-native@"*" from [email protected]
npm ERR!   node_modules/expo-file-system
npm ERR!     peer expo-file-system@"^9.2.0" from [email protected]
npm ERR!     node_modules/redux-persist-expo-fs-storage
npm ERR!       redux-persist-expo-fs-storage@"*" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@">=0.63.3" from [email protected]
npm ERR! node_modules/redux-persist-expo-fs-storage
npm ERR!   redux-persist-expo-fs-storage@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/gregschechter/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/gregschechter/.npm/_logs/2021-08-17T04_42_49_616Z-debug.log

I think this is the root of a bigger issue where the redux state isn't saved. I've tried using legacy-peer-deps which will bypass the error above, but then the redux state doesn't appear to be saved to the filesystem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.