redux-state-local-browser-sync
v1.0.2
Published
A plugin which persists your redux state across local browsers.
Downloads
5
Maintainers
Readme
redux-state-local-browser-sync
A plugin which persists your redux state across local browsers.
Simple configuration steps yet powerful plugin.
Install
npm install --save redux-state-local-browser-sync
Basic Usage
Configure redux-persist in your project.
Import redux-state-local-browser-sync.
Pass in persistConfig and store as props to the imported name of the redux-state-local-browser-sync
Configure redux-persist.
import { createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web
import rootReducer from './reducers'
const persistConfig = {
key: 'root',
storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
export default () => {
let store = createStore(persistedReducer)
let persistor = persistStore(store)
return { store, persistor }
}
Import redux-state-local-browser-sync and pass persistConfig and store as props
import { createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import rootReducer from './reducers'
import localTabReduxStateChanger from "redux-state-local-browser-sync"; //import redux-state-local-browser-sync
const persistConfig = {
key: 'root',
storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
export default () => {
let store = createStore(persistedReducer)
let persistor = persistStore(store)
localTabReduxStateChanger(persistConfig,store) //pass persistConfig and store
return { store, persistor }
}
License
MIT © ashwinKumar0505