redux-persist-cordova-sqlite
v1.0.0
Published
use sqlite with redux persist in cordova based apps
Downloads
404
Maintainers
Readme
redux-persist-cordova-sqlite
use sqlite with redux persist in cordova based apps
Install
npm install --save redux-persist-cordova-sqlite
Usage
store.js
import { createStore, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import reducer from "./reducer";
import { persistStore, persistReducer } from "redux-persist";
import {sqlLiteStorage} from 'redux-persist-cordova-sqlite';
export default () => {
const persistConfig = {
key: 'root',
storage: sqlLiteStorage()
}
const persistedReducer = persistReducer(persistConfig, reducer);
let store = createStore(persistedReducer, applyMiddleware(thunk));
let persistor = persistStore(store);
return { store, persistor };
};
~.~.~.~.~.~.~
App.jsx
import getStoreAndPersistor from 'store'
export default function App() {
const { store, persistor } = getStoreAndPersistor();
return (
<Provider store={store}>
<PersistGate loading={<div></div>} persistor={persistor}>
<HashRouter>
<Main />
</HashRouter>
</PersistGate>
</Provider>
);
}
License
MIT © sumedh22