Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable no-underscore-dangle */
const devtoolsExtensionCompose = isDevelopment
&& isObject(window)
&& window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
/* eslint-enable no-underscore-dangle */
const middleware = isDevelopment
? [thunkMiddleware, createLogger({ diff: true, collapsed: true })]
: [thunkMiddleware];
const composeEnhancers = devtoolsExtensionCompose || compose;
const enhancer = composeEnhancers(applyMiddleware(...middleware));
export const store = createStore(rootReducer, enhancer);
export const persistor = persistStore(store);
/* eslint-enable no-undef */
const enhancer = composeEnhancers(...enhancers);
const persistConfig = {
key: 'root',
storage,
};
const persistedReducer = persistReducer(persistConfig, reducer);
export const store = createStore(
persistedReducer,
{},
enhancer,
);
export const persistor = persistStore(store);
const configureStore = callback => {
// mount it on the Store
const store = createStore(
rootReducer,
initialState,
compose(
// if you use getStoredState then no need to use auto hydrate to get state back
autoRehydrate(),
applyMiddleware(...middleware),
)
)
// then run the saga
sagaMiddleware.run(rootSaga)
persistStore(store, {storage: AsyncStorage}, ()=> callback(store))
}
import { AsyncStorage } from 'react-native';
import { createStore, applyMiddleware } from 'redux';
import { persistStore, autoRehydrate, purgeStoredState } from 'redux-persist';
import appReducer from '../reducers/AppReducer';
const todosStore = createStore(
appReducer,
undefined,
autoRehydrate()
);
persistStore(todosStore, {storage: AsyncStorage});
// purgeStoredState({storage: AsyncStorage}) // Clear persistStore
export default todosStore;
}
const storeEnhancer = applyMiddleware(...middlewares);
const store: Store = createStore(
rootReducer,
defaultState,
composeEnhancers(storeEnhancer),
);
if (module.hot) {
// Enable webpack hot module replacement for reducers
module.hot.accept('../reducers', () => store.replaceReducer(rootReducer));
}
const persistor = persistStore(store);
return { persistor, store };
}
cart,
),
navbar,
search,
toastr,
});
const history = createHistory();
const store = createStore(
rootReducer,
undefined,
applyMiddleware(thunk, routerMiddleware(history)),
);
persistStore(store);
export { history };
export default store;
const rootReducer = connectRouter(history)(reducer);
const epicMiddleware = createEpicMiddleware(rootEpic);
const enhancers = composeWithDevTools(
applyMiddleware(
routerMiddleware(history),
epicMiddleware
),
autoRehydrate()
);
const store = initialState
? createStore(rootReducer, initialState, enhancers)
: createStore(rootReducer, enhancers);
persistStore(store, {
keyPrefix: "fttv:",
whitelist: ["settings", "user"]
});
if ((process.env.NODE_ENV === "development") && module.hot) {
module.hot.accept("data", () => {
store.replaceReducer(connectRouter(history)(reducer));
epicMiddleware.replaceEpic(rootEpic);
});
}
return store;
};
import {persistStore, autoRehydrate} from "redux-persist";
import {applyMiddleware, createStore, compose} from "redux";
import {AsyncStorage} from "react-native";
import thunk from "redux-thunk";
import createLogger from "redux-logger";
import rootReducer from "./rootReducer";
const logger = createLogger();
const store = createStore(rootReducer, compose(
applyMiddleware(thunk, logger),
autoRehydrate()
));
persistStore(store, {storage: AsyncStorage});
export default store;
});
const persistConfig = {
key: 'root',
storage: storage,
};
const persistedReducer = persistReducer(persistConfig, rootReducer);
const store = createStore(
persistedReducer,
process.env.NODE_ENV === 'development' && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
);
export default store;
export let persistor = persistStore(store);
public componentWillMount() {
const onDone = () => this.setState({ rehydrated: true });
persistStore(store,
{whitelist: ['authKey', 'currentUser', 'currentDc']}, onDone);
}