1.0.10 • Published 3 years ago

@sparkyflash/redux-persist-store v1.0.10

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

@sparkyflash/redux-persist-store

@sparkyflash/redux-persist-store is allow you to achieve persist redux store.

Current Version

1.0.10

Install

npm

npm install --save @sparkyflash/redux-persist-store

Quick Start

2 Easy Steps

1. Initiating persistState to the redux store. By default sessionStorage will be considered for storage.

import { createStore as reduxCreateStore, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import app from "../reducers";
import { persistState } from "@sparkyflash/redux-persist-store";

const createStore = () =>
  reduxCreateStore(app, persistState(), applyMiddleware(thunk));

export default createStore;

Even you can pass options to persistState to specify the storage. It is flexible to inject any ecryption/serialization algorithm in encryption property.

import { createStore as reduxCreateStore, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import app from "../reducers";
import { persistState } from "@sparkyflash/redux-persist-store";
const persistOptions = {
  storage: sessionStorage,
  encryption: {
    encrypt: (data) => {
      return data;
    },
    decrypt: (data) => {
      return data;
    },
  },
};

const createStore = () =>
  reduxCreateStore(app, persistState(persistOptions), applyMiddleware(thunk));

export default createStore;

2. Wrapping the component with PersistWrapper.

import React from "react";
import { Provider } from "react-redux";
import createStore from "./createStore";
import { PersistWrapper } from "@sparkyflash/redux-persist-store";

export default ({ element }) => (
  <Provider store={createStore()}>
    <PersistWrapper>{element}</PersistWrapper>
  </Provider>
);
1.0.9

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago