Skip to content

psr1919plus21/sync-redux-with-localstorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is middleware for sync redux store with localStorage

Every time when store change occurs, specified field automatically write to localStorage

Download

npm i sync-redux-with-localstorage -D

Example:

store

state.cats = [
   {
    name: 'Fat Cat',
    id: 1,
  },
 {
    name: 'Good Cat',
    id: 2,
  },
];

interface

const syncInterface = {
  cats: {
    id: true,
  },
}

usage

import syncReduxWithLocalstorage from 'sync-redux-with-localstorage';

export default createStore(
    rootReducer,
    composeWithDevTools(applyMiddleware(thunk, syncReduxWithLocalstorage(syncInterface))),
);

in localStorage will be saved:

  reduxLocalStorage: "{ "cats" : [{ "id": "1" }, { "id": "2" }]}"

About

middleware for sync redux field with localStorage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published